设置在高德API setFitView方法导致的中心点和缩放与初始化不一致的问题的问题调优

This commit is contained in:
aixianling
2023-10-10 10:25:46 +08:00
parent c776c1d733
commit 5b09630e62

View File

@@ -183,13 +183,6 @@ export default {
this.timer && clearInterval(this.timer)
if (AMap && map) {
map.clearMap()
const center = map.getCenter()
const zoom = map.getZoom()
map.on('click', () => {
map.setZoomAndCenter(zoom, center)
map.setPitch(0)
this.mapDialog = false
})
const markers = Array.isArray(this.values) ? this.values : this.values.markers
const polylines = Array.isArray(this.values) ? [] : this.values.polylines || []
markers.map(e => ({lng: e['经度'], lat: e['纬度'], label: e['地区名称'], ...e})).filter(e => e.lng).map((e) => {
@@ -214,6 +207,13 @@ export default {
map, strokeColor: "#00FFAE", ...e, path: e.path.map(p => new AMap.LngLat(p[1], p[0]))
}))
map.setFitView()
const center = map.getCenter()
const zoom = map.getZoom()
map.on('click', () => {
map.setZoomAndCenter(zoom, center)
map.setPitch(0)
this.mapDialog = false
})
this.data.is3d > 0 && map.setPitch(65)
if (this.data.is3dAround == 1) {
this.timer = setInterval(() => map.setRotation(360, false, 16000))