wgs2mars
Version:
a little function to transform longitude and latitude from WGS-84 To GCJ-02
48 lines (43 loc) • 1.13 kB
HTML
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>China border GPS data</title>
<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=811417de1d755929db362be5ac388721"></script>
<script type="text/javascript" src="../lib/border-data-all.js"></script>
<style>
#map {
width: 100%;
height: 600px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var mapObj;
function mapInit() {
mapObj = new AMap.Map("map", {
//二维地图显示视口
view: new AMap.View2D({
zoom: 4 //地图显示的缩放级别
})
});
AMap.event.addListener(mapObj, 'complete', function () {
for (var i = 0; i < borderData.length; i++) {
addMarker(borderData[i][0], borderData[i][1]);
}
});
}
//在地图上添加点标记函数
function addMarker(lng, lat) {
marker = new AMap.Marker({
content: lng + ' : ' + lat,
position: new AMap.LngLat(lng, lat)
});
marker.setMap(mapObj); //在地图上添加点
}
mapInit();
</script>
</body>
</html>