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