把查询地图显示和IP查询分开了,这样你可以很容易加到你原有的IP查询系统里!
原理:借助google maps显示其IP所在地地图位置。(需要申请个google的key)
文件:你自己的IP查询程序+一个HTML页即可
HTML文件2.htm代码
引用格式:
http://www.ipfox.com.cn/2.htm?广东省深圳市罗湖区2.htm代码:
复制内容到剪贴板
代码:
<script src="http://ditu.google.com/maps?file=api&v=2.x&key=ABQIAAAAxrryO9ztNllJV478OHgoUhSldR1ND_txlcuxRl8_AG4iJh50ABTWAsb98SF8PpXkDnxpLXR4LWsFug&hl=zh-CN" type="text/javascript"></script>
<script type="text/javascript">
var map = null;
var geocoder = null;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
geocoder = new GClientGeocoder();
var address;
if (document.location.search == ""){
address= "";
}else{
address= document.location.search.substr(1);
}
if (geocoder) {
geocoder.getLatLng(
address,
function(point) {
if (!point) {
//alert("不能解析: " + address);
document.write("载入地址发生错误!请联系ipfox.com.cn管理员");
} else {
map.setCenter(point, 13);
var icon = new GIcon (G_DEFAULT_ICON, "ipfox.gif");
icon.iconSize = new GSize (32, 39);
var marker = new GMarker(point, icon);
map.addOverlay(marker);
map.enableScrollWheelZoom();
map.addControl(new GSmallMapControl());
map.addControl(new GScaleControl());
//map.addControl(new GMapTypeControl());
var txt = "<div style=\"font-family:Arial,Helvetica,Sans Serif;font-size:11px;text-align:center\">";
txt += "你所查询的IP所在地<br><font color=ff0000>";
txt += address+"</font><br>地理位置坐标<br>ipfox.com.cn为您提供"
txt += "<" + "/div>";
marker.openInfoWindowHtml(txt);
}
}
);
}
}
}
</script>
</head>
<body onLoad="initialize()" onUnload="GUnload()">
<div id="map_canvas" style="width: 500px; height: 340px">正在载入IP地理位置图...</div>大家也可以直接下载文件使用。