提交 4bbbbce0 编写于 作者: Q qiang

fix: 修复 App 端 map 组件 markers 无 id 时无法移除的问题

上级 6dcf012a
......@@ -194,7 +194,8 @@ export default {
mapStyle.center = new plus.maps.Point(this.longitude, this.latitude)
}
const map = this.map = plus.maps.create(this.$page.id + '-map-' + (this.id || Date.now()), mapStyle)
map.__markers__ = {}
map.__markers__ = []
map.__markers_map__ = {}
map.__lines__ = []
map.__circles__ = []
map.setZoom(parseInt(this.scale))
......@@ -317,16 +318,18 @@ export default {
}
}
nativeMap.addOverlay(nativeMarker)
nativeMap.__markers__[id + ''] = nativeMarker
nativeMap.__markers__.push(nativeMarker)
nativeMap.__markers_map__[id + ''] = nativeMarker
})
},
_clearMarkers () {
const map = this.map
const data = map.__markers__
for (const key in data) {
map.removeOverlay(data[key])
}
map.__markers__ = {}
const markers = map.__markers__
markers.forEach(marker => {
map.removeOverlay(marker)
})
map.__markers__ = []
map.__markers_map__ = {}
},
_addMarkers (markers, clear) {
if (this.map) {
......@@ -352,7 +355,7 @@ export default {
markerId
}) {
if (this.map) {
const nativeMarker = this.map.__markers__[markerId + '']
const nativeMarker = this.map.__markers_map__[markerId + '']
if (nativeMarker) {
nativeMarker.setPoint(new plus.maps.Point(destination.longitude, destination.latitude))
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册