From 2e553b48ca671a6bf0c238d653add5d8872ec09b Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Sun, 29 Sep 2024 15:17:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0map=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/component/map/map.uvue | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/pages/component/map/map.uvue b/pages/component/map/map.uvue index c8a893da..010e590b 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', -- GitLab