提交 2e553b48 编写于 作者: Anne_LXM's avatar Anne_LXM

更新map示例

上级 181de5fb
...@@ -377,28 +377,34 @@ ...@@ -377,28 +377,34 @@
let markers = ref([] as Marker[]); let markers = ref([] as Marker[]);
const addMarkers = () => { const addMarkers = () => {
scale.value = 11 scale.value = 11
const temp = JSON.parse<Marker[]>(JSON.stringify(testMarkers))! const temp = JSON.parse<Marker[]>(JSON.stringify(testMarkers))!
markers.value = temp markers.value = temp
}; };
const removeMarker = () => { const removeMarker = () => {
const index = markers.value.findIndex((marker: Marker):boolean=>{ // #ifdef APP
return marker.id == 4 mapContext.value?.removeMarkers({markerIds:[4]})
// #endif
// #ifdef WEB
const index = markers.value.findIndex((marker: Marker):boolean=>{
return marker.id == 4
}); });
if (index != -1) { if (index != -1) {
mapContext.value?.removeMarkers({markerIds:[4]}) delete markers.value[index].label;
markers.value.splice(index, 1);
} else { } else {
uni.showToast({ uni.showToast({
title: '未找到该标记点', title: '未找到该标记点',
icon: 'none' icon: 'none'
}); });
} }
// #endif
}; };
// #ifdef WEB // #ifdef WEB
const addMarkersLabel = () => { const addMarkersLabel = () => {
markers.forEach((marker, index) => { markers.value.forEach((marker, index) => {
marker.label = { marker.label = {
content: 'Hello Label' + (index + 1), content: 'Hello Label' + (index + 1),
color: '#aa00ff', color: '#aa00ff',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册