hookehuyr

新增手动触发定位操作

......@@ -11,7 +11,6 @@ declare module '@vue/runtime-core' {
export interface GlobalComponents {
AudioBackground: typeof import('./src/components/audioBackground.vue')['default']
AudioBackground1: typeof import('./src/components/audioBackground1.vue')['default']
copy: typeof import('./src/components/audioBackground copy.vue')['default']
Floor: typeof import('./src/components/Floor/index.vue')['default']
InfoPopup: typeof import('./src/components/InfoPopup.vue')['default']
InfoPopupLite: typeof import('./src/components/InfoPopupLite.vue')['default']
......
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-09-21 11:01:31
* @LastEditTime: 2024-09-21 12:03:00
* @FilePath: /map-demo/src/views/bieyuan/map.vue
* @Description: 公众地图主体页面
-->
......@@ -59,6 +59,19 @@
<!-- 背景音乐控制 -->
<!-- <audioBackground1></audioBackground1> -->
<div class="operate-bar-wrapper">
<div class="box-wrapper">
<div v-if="open_current_location" class="item" @click="handleLocation(true)">
<van-icon name="https://cdn.ipadbiz.cn/xys/map/%E5%AE%9A%E4%BD%8Dloc@2x.png" size="1.5rem"
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);;" />
</div>
<div v-else class="item" @click="handleLocation(false)">
<van-icon name="https://cdn.ipadbiz.cn/xys/map/%E5%AE%9A%E4%BD%8Dloc@2x.png" size="1.5rem"
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" />
</div>
</div>
</div>
</div>
</template>
......@@ -203,6 +216,7 @@ export default {
current_safe_route: [],
route_safe_marker: [],
show_walk_route: true,
open_current_location: true,
}
},
async mounted() {
......@@ -373,10 +387,10 @@ export default {
});
this.map.add(this.markerSum);
//
setTimeout(() => {
// 获取定位打标记
this.setLocation();
}, 1000);
// setTimeout(() => {
// // 获取定位打标记
// this.setLocation();
// }, 1000);
},
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
......@@ -763,7 +777,21 @@ export default {
console.warn(marker_id);
// 模拟新增路线
this.addSafeRoute(this.data_path_list[0]);
},
handleLocation(status) { // 打开/关闭 当前定位
if (status) {
this.setLocation()
this.open_current_location = false;
} else {
this.removeLocation()
this.open_current_location = true;
}
},
removeLocation() { // 移除定位标记
this.current_lng = '';
this.current_lat = '';
this.map.remove(this.location_marker); // 删除当前定位标记
},
}
}
</script>
......