跳转第三方高德、百度导航
代码示例
var lat = obj.lat;
var lon = obj.lon;
var uri = "androidamap://navi?sourceApplication=" + api.appName + "&poiname=fangheng&lat=" + lat + "&lon=" + lon + "&dev=1&style=2";
api.openApp({
androidPkg: 'android.intent.action.VIEW',
appParam: {
lat: lat,
lon: lon,
dev: '1',
style: '2',
sourceApplication: api.appName
},
uri: uri,
iosUrl: 'iosamap://navi'
}, function(ret, err) {
if (ret) {
} else {
// 未安装高德 -- 尝试百度导航
var baiduUri = 'intent://map/direction?destination=latlng:' + lat + ',' + lon + '|name:我的目的地&mode=driving&src=' + api.appName + '#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end';
api.openApp({
androidPkg: 'android.intent.action.VIEW',
appParam: {
destination: lat + ',' + lon,
mode: 'driving',
sourceApplication: api.appName
},
uri: baiduUri,
iosUrl: 'baidumap://map/direction'
}, function(ret, err) {
if (ret) {
} else {
api.toast({
msg: '未安装高德或百度导航',
duration: 2000,
location: 'middle'
});
}
})
}
})
共有 0 条评论