针对uniapp开发的app/微信小程序需要拉起导航
####首先需要配置manifest.json中的地图模块
![请添加图片描述](https://img-blog.csdnimg.cn/d72910a862264efab3882eb7d9b3de0f.png?x-oss-process=image/watermark,type_ZHJvaWRzYW5zZmFsbGJhY2s,shadow_50,text_Q1NETiBARW5qb3lCZWF1dGlmdWxMaWZl,size_19,color_FFFFFF,t_70,g_se,x_16)
- APP端
if (plus.os.name == 'Android') {
plus.nativeUI.actionSheet({
title: '选择地图应用',
cancel: '取消',
buttons: [{
title: '高德地图'
}]
},
function(e) {
switch (e.index) {
case 1:
url =
`androidamap://viewMap?sourceApplication=appname&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
break;
default:
break;
}
if (url != '') {
url = encodeURI(url);
plus.runtime.openURL(url, function(e) {
plus.nativeUI.alert('本机未安装指定的地图应用');
});
}
}
);
} else {
plus.nativeUI.actionSheet({
title: '选择地图应用',
cancel: '取消',
buttons: [{
title: '高德地图'
}]
},
function(e) {
switch (e.index) {
case 1:
url =
`iosamap://viewMap?sourceApplication=applicationName&poiname=${name}&lat=${latitude}&lon=${longitude}&dev=0`;
break;
default:
break;
}
if (url != '') {
url = encodeURI(url);
plus.runtime.openURL(url, function(e) {
plus.nativeUI.alert('本机未安装指定的地图应用');
});
}
}
);
}
- 微信小程序
openGuide(item) {
console.log('走的这里', item);
wx.openLocation({
latitude: +item.latitude,
longitude: +item.longitude,
name:item.address,
address:item.address,
success:function(r){
console.log(r)
},
fail: function (res) {
console.log('拉起失败啦', res)
}
})
},