// 目標(biāo)緯度
public latitude = '10.455';
// 目標(biāo)經(jīng)度
public longitude = '123.567';
// 目標(biāo)地址名稱
public name = '高鐵站';
// 目標(biāo)地址詳細(xì)信息
public address = '';
// 我自己的位置經(jīng)緯度(百度地圖需要傳入自己的經(jīng)緯度進(jìn)行導(dǎo)航)
public myLocation = {
latitude: 17.1234,
longitude: 84.3465686
};
public handleNavigation() {
// #ifdef APP-PLUS
// 判斷系統(tǒng)安裝的地圖應(yīng)用有哪些, 并生成菜單按鈕
let mapList = [
{ title: '高德地圖', name: 'amap', androidName: 'com.autonavi.minimap', iosName: 'iosamap://' },
{ title: '百度地圖', name: 'baidumap', androidName: 'com.baidu.BaiduMap', iosName: 'baidumap://' },
{ title: '騰訊地圖', name: 'qqmap', androidName: 'com.tencent.map', iosName: 'qqmap://' }
];
// 根據(jù)真機(jī)有的地圖軟件 生成的 操作菜單
let buttons: Array<any> = [];
let platform = uni.getSystemInfoSync().platform;
platform === 'android' &&
mapList.forEach(item => {
if (plus.runtime.isApplicationExist({ pname: item.androidName })) {
buttons.push(item);
}
});
platform === 'ios' &&
mapList.forEach(item => {
console.log(item.iosName);
if (plus.runtime.isApplicationExist({ action: item.iosName })) {
buttons.push(item);
}
});
if (buttons.length) {
plus.nativeUI.actionSheet(
{
//選擇菜單
title: '選擇地圖應(yīng)用',
cancel: '取消',
buttons: buttons
},
e => {
let _map = buttons[e.index - 1];
this.openURL(_map, platform);
}
);
} else {
uni.showToast({
title: '請安裝地圖軟件',
icon: 'none'
});
return;
}
// #endif
}
// 打開第三方程序?qū)嶋H應(yīng)用
public openURL(map, platform) {
let urls = {
android: {
amap: `amapuri://route/plan/?sid=&did=&dlat=${this.latitude}&dlon=${this.longitude}&dname=${this.name}&dev=0&t=0`,
qqmap: `qqmap://map/routeplan?type=drive&to=${this.name}&tocoord=${this.latitude},${this.longitude}&referer=ixinyi_client`,
baidumap: `baidumap://map/direction?origin=${this.myLocation.latitude},${this.myLocation.longitude}&destination=name:${this.name}|latlng:${this.latitude},${this.longitude}&coord_type=wgs84&mode=driving&src=andr.baidu.openAPIdemo"`
},
ios: {
amap: `iosamap://path?sourceApplication=ixinyi_client&dlat=${this.latitude}&dlon=${this.longitude}&dname=${this.name}&dev=0&t=0`,
qqmap: `qqmap://map/routeplan?type=drive&to=${this.name}&tocoord=${this.latitude},${this.longitude}&referer=ixinyi_client`,
baidumap: `baidumap://map/direction?origin=${this.myLocation.latitude},${this.myLocation.longitude}&destination=name:${this.name}|latlng:${this.latitude},${this.longitude}&mode=driving&src=ios.baidu.openAPIdemo`
}
};
let newurl = encodeURI(urls[platform][map.name]);
console.log(newurl);
plus.runtime.openURL(
newurl,
function (res) {
uni.showModal({
content: res.message
});
},
map.androidName ? map.androidName : ''
);
}
uniapp跳轉(zhuǎn)三方地圖導(dǎo)航
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 高德:打開高德地圖API>開發(fā)支持>點擊開發(fā)文檔(居然可以點擊...)>高德地圖手機(jī)版(在"其他"類下)>左側(cè)路徑...
- 1.獲取地圖導(dǎo)航路線坐標(biāo) https://lbs.amap.com/console/show/picker 高德...
- 最近有個需求,就是在自己的app項目里面直接根據(jù)定位,跳轉(zhuǎn)進(jìn)入百度或者高德地圖進(jìn)行導(dǎo)航。 如果手機(jī)同時安裝高德和百...
- 整理一下iOS跳轉(zhuǎn)第三方地圖導(dǎo)航的方法 1.獲取定位權(quán)限 2.添加跳轉(zhuǎn)第三方地圖App的白名單 3.代碼示例 以上...
- github地址百度地圖文檔高德地圖文檔 一.說明 在使用地圖的時候,需要用到定位系統(tǒng),有定位就要有坐標(biāo)系。 但是...