根据IP地址显示地图demo

本文是演示根据IP地址自动加载地图位置的demo。具体思路为:1,利用GeoLiteCity取得当前位置的经纬度
具体参见php 利用Google Weather Api读取天气预报
2,使用经纬度坐标初始化地图,本文以mapbar为例
<script type="text/javascript" src="http://union.mapbar.com/apis/maps/free?f=mapi&v=31.2&k=yourdomainkey"></script>
<script type="text/javascript">
var maplet = null;
function initMap(){
maplet = new Maplet("mapbar");
maplet.centerAndZoom(new MPoint(<?=$longitude?>,<?=$latitude?>), 8);
maplet.addControl(new MStandardControl());
}
</script>
</head>
<body onload="initMap()">
<div id="mapbar" style="width:800px;height:600px"></div>
</body>




