性能优化
This commit is contained in:
parent
4a4b3d745d
commit
7496c9bb37
@ -149,6 +149,17 @@ AMapLoader.load({
|
||||
zoom: 14,
|
||||
});
|
||||
console.log("地图对象", map)
|
||||
map.on("moveend",()=>{
|
||||
let bounds = map.getBounds()
|
||||
data.markers.forEach(marker=>{
|
||||
if(bounds.contains(marker.getPosition())) {
|
||||
marker.show()
|
||||
} else {
|
||||
marker.hide()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
map.addControl(scale)
|
||||
map.addControl(toolBar)
|
||||
map.addControl(controlBar)
|
||||
@ -281,6 +292,7 @@ function search() {
|
||||
|
||||
return marker;
|
||||
})
|
||||
data.markers = markers
|
||||
labelsLayer.add(markers)
|
||||
map.add(data.labelsLayer)
|
||||
|
||||
@ -320,11 +332,6 @@ function search() {
|
||||
data.polylines.push(polyline)
|
||||
})
|
||||
console.log("polylines",data.polylines)
|
||||
|
||||
if (data.polylines.length > 0) {
|
||||
map.panTo(data.polylines[0].getPath()[0])
|
||||
map.setFitView()
|
||||
}
|
||||
// polyline = new AMap.Polyline({
|
||||
// path: path,
|
||||
// showDir: true,
|
||||
@ -336,7 +343,11 @@ function search() {
|
||||
// lineJoin: 'round' // 折线拐点连接处样式})
|
||||
// })
|
||||
map.add(data.polylines)
|
||||
|
||||
setTimeout(()=>{
|
||||
if (data.polylines.length > 0) {
|
||||
map.setFitView()
|
||||
}
|
||||
})
|
||||
fixedLocation()
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user