diff --git a/pages/component/map/map.uvue b/pages/component/map/map.uvue index c8a893da95e378e4ffc9e2822e3200f40a566297..010e590be7b299164215c10092a459bf8a3d34d2 100644 --- a/pages/component/map/map.uvue +++ b/pages/component/map/map.uvue @@ -377,28 +377,34 @@ let markers = ref([] as Marker[]); const addMarkers = () => { - scale.value = 11 - const temp = JSON.parse(JSON.stringify(testMarkers))! + scale.value = 11 + const temp = JSON.parse(JSON.stringify(testMarkers))! markers.value = temp }; const removeMarker = () => { - const index = markers.value.findIndex((marker: Marker):boolean=>{ - return marker.id == 4 + // #ifdef APP + mapContext.value?.removeMarkers({markerIds:[4]}) + // #endif + // #ifdef WEB + const index = markers.value.findIndex((marker: Marker):boolean=>{ + return marker.id == 4 }); - if (index != -1) { - mapContext.value?.removeMarkers({markerIds:[4]}) + if (index != -1) { + delete markers.value[index].label; + markers.value.splice(index, 1); } else { uni.showToast({ title: '未找到该标记点', icon: 'none' }); } + // #endif }; // #ifdef WEB const addMarkersLabel = () => { - markers.forEach((marker, index) => { + markers.value.forEach((marker, index) => { marker.label = { content: 'Hello Label' + (index + 1), color: '#aa00ff',