hookehuyr

fix 步行导航功能优化

......@@ -3,8 +3,8 @@ VITE_PORT = 8006
# 反向代理服务器地址
# VITE_PROXY_TARGET = https://oa-dev.onwall.cn
VITE_PROXY_TARGET = https://bm.jiqun.com
# VITE_PROXY_TARGET = https://oa.onwall.cn
# VITE_PROXY_TARGET = https://bm.jiqun.com
VITE_PROXY_TARGET = https://oa.onwall.cn
# API请求前缀
VITE_PROXY_PREFIX = /srv/
......
{
"globals": {
"EffectScope": true,
"ElMessage": true,
"computed": true,
"createApp": true,
"customRef": true,
......
......@@ -2,6 +2,7 @@
export {}
declare global {
const EffectScope: typeof import('vue')['EffectScope']
const ElMessage: typeof import('element-plus/es')['ElMessage']
const computed: typeof import('vue')['computed']
const createApp: typeof import('vue')['createApp']
const customRef: typeof import('vue')['customRef']
......
<!--
* @Date: 2024-09-15 22:08:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-06 09:50:03
* @LastEditTime: 2025-03-06 12:12:52
* @FilePath: /map-demo/src/views/by/info.vue
* @Description: 文件描述
-->
......@@ -256,7 +256,7 @@ onMounted(async () => {
link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl: '', // 分享图标
success: function () {
console.warn('设置成功');
// console.warn('设置成功');
}
}
// 分享好友(微信好友或qq好友)
......@@ -314,18 +314,6 @@ const goTo = () => { // 打开标记地图显示
}
const goToWalk = async () => { // 打开步行导航地图显示
// 没有关联导航提示
try {
const isLocationEnabled = await checkWxLocation();
if (!isLocationEnabled) {
// 提示用户开启定位
show_toast.value = true;
toast_text.value = '请开启手机定位功能';
return;
}
} catch (err) {
console.error('获取定位状态失败:', err);
}
//
if ($router.currentRoute.value.path === '/by/info') { // 详情页
$router.push({
......@@ -483,24 +471,6 @@ const onStatusAudioList = (status) => { // 音频列表组件,状态改变
// show_audio.value = false;
// }
}
const checkWxLocation = () => {
return new Promise((resolve, reject) => {
wx.getLocation({
type: 'gcj02', // 默认为 wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
success: (res) => {
resolve(true); // 已开启定位
},
fail: (err) => {
if (err.errMsg.indexOf('deny') > -1) {
resolve(false); // 未开启定位
} else {
reject(err); // 其他错误
}
}
});
});
}
</script>
<style lang="less">
......
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-03-06 10:36:30
* @LastEditTime: 2025-03-06 12:14:54
* @FilePath: /map-demo/src/views/by/map.vue
* @Description: 公众地图主体页面
-->
......@@ -322,7 +322,7 @@ export default {
link: location.origin + location.pathname + location.hash, // 分享链接,该链接域名或路径必须与当前页面对应的公众号 JS 安全域名一致
imgUrl: '', // 分享图标
success: function () {
console.warn('设置成功');
// console.warn('设置成功');
}
}
// 分享好友(微信好友或qq好友)
......@@ -335,17 +335,17 @@ export default {
this.initMap();
// this.setMapBoundary();
// 使用之前获取当前地址,判断当前是否能够获取经纬度
wx.getLocation({
type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: (res) => {
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
var speed = res.speed; // 速度,以米/每秒计
var accuracy = res.accuracy; // 位置精度
this.current_lng = GPS.gcj_encrypt(latitude, longitude).lon;
this.current_lat = GPS.gcj_encrypt(latitude, longitude).lat;
},
});
// wx.getLocation({
// type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
// success: (res) => {
// var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
// var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
// var speed = res.speed; // 速度,以米/每秒计
// var accuracy = res.accuracy; // 位置精度
// this.current_lng = GPS.gcj_encrypt(latitude, longitude).lon;
// this.current_lat = GPS.gcj_encrypt(latitude, longitude).lat;
// },
// });
// 设置贴片地图
this.setTitleLayer();
// 地图标题
......@@ -548,8 +548,23 @@ export default {
if (marker_id) {
this.$nextTick(() => {
let marker = this.navBarList[0]['list'].filter(item => item.id == marker_id)
let path = marker[0].path;
this.addSafeRoute({name: '参观路径', path});
// let path = marker[0].path;
// this.addSafeRoute({name: '参观路径', path});
// TAG: 新增步行导航
let position = marker[0].position;
wx.getLocation({
type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: (res) => {
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
var speed = res.speed; // 速度,以米/每秒计
var accuracy = res.accuracy; // 位置精度
this.current_lng = GPS.gcj_encrypt(latitude, longitude).lon;
this.current_lat = GPS.gcj_encrypt(latitude, longitude).lat;
this.onWalkRoute({point: position});
},
});
// 获取当前 URL 的查询参数
let query = { ...this.$route.query };
......@@ -971,6 +986,16 @@ export default {
// panel: "panel"
// });
wx.getLocation({
type: 'wgs84', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02'
success: (res) => {
var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90
var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。
var speed = res.speed; // 速度,以米/每秒计
var accuracy = res.accuracy; // 位置精度
this.current_lng = GPS.gcj_encrypt(latitude, longitude).lon;
this.current_lat = GPS.gcj_encrypt(latitude, longitude).lat;
// 确保参数格式正确
const startPoint = [this.current_lng, this.current_lat]; // 起点
const endPoint = position.point; // 终点
......@@ -1002,6 +1027,8 @@ export default {
}
});
},
});
},
handleLocation(status) { // 打开/关闭 当前定位
if (status) {
this.setLocation()
......