百度地图API获取多个覆盖物的信息

<script type=”text/javascript”>

var point = new BMap.Point(120.381001,36.096903);
var map = new BMap.Map(“allmap”);
map.centerAndZoom(point, 19);
var pointlist=new Array(“120.381001,36.096903″,”120.381201,36.096903″,”120.381401,36.096903″,”120.381601,36.096903″,”120.381801,36.096903”);
var count=pointlist.length;
var i=0;
for(;i<count;i++){
var strpoint=pointlist[i].split(“,”);
var pointX=strpoint[0];
var pointY=strpoint[1];
var point = new BMap.Point(pointX,pointY);
var marker = new BMap.Marker(point);
map.addOverlay(marker);
(function () {
marker.addEventListener(“click”, function () {
var p = this.getPosition();
alert(“marker1的位置是” + p.lng + “,” + p.lat);
});
})()
}
</script>

未经允许不得转载:前端撸码笔记 » 百度地图API获取多个覆盖物的信息

上一篇:

下一篇: