落日与鲸
2025-02-25 245aba1595bb2b5ce6c5415386a30aeb0cb2e632
定位点
1个文件已修改
14 ■■■■ 已修改文件
H5/pages/location/location.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
H5/pages/location/location.vue
@@ -43,11 +43,18 @@
                uid: 0,
                keyword: '',
                locationList: [],
                city: '攀枝花市'
                city: '攀枝花市',
                markers:[],
            };
        },
        methods: {
 clearMarkers() {
            // 清除所有标点
            this.markers.forEach((marker) => {
                this.map.removeOverlay(marker);
            });
            this.markers = []; // 清空存储标点的数组
        },
            back() {
                uni.navigateBack()
            },
@@ -150,6 +157,7 @@
            this.map.centerAndZoom(point, 12);
            var marker = new BMapGL.Marker(point);
            this.map.addOverlay(marker);
            this.markers.push(marker);
            var myGeo = new BMapGL.Geocoder();
            // 根据坐标得到地址描述    
            myGeo.getLocation(new BMapGL.Point(res.longitude, res.latitude), (result) => {
@@ -160,6 +168,7 @@
            })
            this.map.addEventListener('click', (e) => {
                this.clearMarkers()
                var mercator = this.map.lnglatToMercator(e.latlng.lng, e.latlng.lat);
                this.latitude = e.latlng.lat
                this.longitude = e.latlng.lng
@@ -177,6 +186,7 @@
                })
                var marker = new BMapGL.Marker(point);
                this.map.addOverlay(marker);
                this.markers.push(marker);
            });
            // },
            // error:err=>{