uni.openLocation起始点定位,IOS手机无法返回等问题

uni.openLocation使用问题

环境:uni-app开发H5项目,H5项目链接webview嵌入app中
在这里插入图片描述

目的:打开目标的地图位置并进行导航,导航完成后退出回到原界面
问题

  • 仅能传入目标地点,还需点击定位后再点击导航才能开始导航
  • 直接点击导航只有默认起点进行选择,并不能根据当前位置返回可选地点
  • 导航完成点击返回时,在IOS手机会出现返回无效的情况

解决:不使用该API,修改当前路径为地图页面路径直接进行导航

openLocation(e) {
    const { latitude, longitude, address } = e.currentTarget.dataset;

    if (latitude && longitude) {
        // #ifdef H5
        let url = `https://apis.map.qq.com/tools/routeplan/eword=${address}&epointx=${latitude}&epointy=${longitude}?referer=${应用名称}&key=${腾讯地图的key}`
        window.location.href = url
        // #endif
        // #ifdef MP-WEIXIN
        uni.openLocation({
            latitude: Number(latitude),
            longitude: Number(longitude),
            name: address || ''
        });
        // #endif
    }
},

猜你喜欢

转载自blog.csdn.net/qq_44242707/article/details/127103800