封装函数
//绘制标注; function getMaker(markerArr) { var allponits=[]; for (var i = 0; i < markerArr.length; i++) { var p0 = markerArr[i].poi_lng; var p1 = markerArr[i].poi_lat; var cat = 0; var txt = markerArr[i].poi_name; var pos = new window.BMap.Point(p0, p1) var maker = addMarker(pos, cat); addInfoWindow(maker, markerArr[i]); //文本标签; addLabel(pos, txt); //设置最佳视野POI; allponits.push(pos); } //console.log(allponits); map.setViewport(allponits); }
解决方案
map.setViewport(allponits);
lockdatav Done!