//创建标注点并添加到地图中
function addMarker(points,area_name) {
if(area_name!=""){
var map = new BMap.Map("allmap");
area_name=area_name.replace(/\s/g, "");
map.centerAndZoom(area_name,13);
}else{
var map = new BMap.Map("allmap");
var pointa = new BMap.Point(114.51767,38.050181);
map.centerAndZoom(pointa,13);
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r) {
if (this.getStatus() == BMAP_STATUS_SUCCESS) {
var mk = new BMap.Marker(r.point);
map.addOverlay(mk);
map.panTo(r.point);
}
});
}
//循环建立标注点
for(var i=0, pointsLen = points.length; i<pointsLen; i++) {
var point = new BMap.Point(points[i].store_longitude, points[i].store_latitude); //将标注点转化成地图上的点
var myIcon = new BMap.Icon(WapSiteUrl+"/images/biaozhu.png", new BMap.Size(25,29));
var marker = new BMap.Marker(point,{icon:myIcon}); //将点转化成标注点
map.addOverlay(marker); //将标注点添加到地图上
}
}
手机百度地图添加标注点
最新推荐文章于 2023-06-19 19:06:58 发布