uni-app App 在使用google map的时候,打开外部地图没法实现定点导航
uni-app App 在使用google map的时候,打开外部地图没法实现定点导航
开发环境 | 版本号 | 项目创建方式 |
---|---|---|
Windows | 10 22H2 | HBuilderX |
产品分类:uniapp/App
PC开发环境操作系统:Windows
HBuilderX类型:正式
HBuilderX版本号:3.8.12
手机系统:Android
手机系统版本号:Android 13
手机厂商:小米
手机机型:Redmi K50
页面类型:vue
vue版本:vue2
打包方式:云端
项目创建方式:HBuilderX
示例代码:
uni.openLocation({
latitude: '22.854575168227097',
longitude: '108.27244097297996',
name: '测试位置',
address: '明细位置明细位置’
})
自查问题
文件位置 plugins\uniapp-cli\node_modules\@dcloudio\uni-app-plus\template\common\__uniappopenlocation.js
, plugins\uniapp-cli\node_modules\@dcloudio\uni-cli-shared\template\common\__uniappopenlocation.js
问题发现
两个文件内使用的google地图接口貌似不生效, ‘www.google.com/maps’ 不生效
https://www.google.com/maps/?daddr="+encodeURIComponent(o)+"&sll="+encodeURIComponent(t+","+n)
解决办法
替换接口如下
https://maps.google.com/maps/?sll="+encodeURIComponent(o)+"&daddr="+encodeURIComponent(t+","+n)
编辑器重新运行到本地,可以正常唤醒谷歌地图并显示导航
操作步骤:
随意一个页面使用 uni.openLocation
唤醒查看位置页面,点击右下角导航按钮,选择谷歌地图,无法展示对应的位置坐标和导航路线
预期结果:
随意一个页面使用 uni.openLocation
唤醒查看位置页面,点击右下角导航按钮,选择谷歌地图,打开并展示对应的标点和导航路线
实际结果:
能唤醒谷歌地图,但无法展示标点和导航路线
bug描述:
App 在使用google map的时候,打开外部地图没法实现定点导航
更多关于uni-app App 在使用google map的时候,打开外部地图没法实现定点导航的实战教程也可以访问 https://www.itying.com/category-93-b0.html
Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse(“geo:0,0?q=37.423156,-122.084917 (” + name + “)”));
startActivity(intent);
更多关于uni-app App 在使用google map的时候,打开外部地图没法实现定点导航的实战教程也可以访问 https://www.itying.com/category-93-b0.html
这个问题是由于Google Maps API的URL格式不正确导致的。在uni-app中调用uni.openLocation时,系统会尝试使用Google Maps的URL格式来打开导航,但当前使用的URL结构存在问题。
根据你的分析,问题出在以下URL格式:
https://www.google.com/maps/?daddr="+encodeURIComponent(o)+"&sll="+encodeURIComponent(t+","+n)
正确的格式应该是:
https://maps.google.com/maps/?sll="+encodeURIComponent(o)+"&daddr="+encodeURIComponent(t+","+n)