更新记录
1.0.0(2024-04-22)
打开手机地图app进行导航路线规划公交搜索搜索周边地铁图等
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:4.4,iOS:9,HarmonyNext:不确定 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
打开手机地图app进行导航路线规划公交搜索搜索周边地铁图等
项目配置
- 在manifest.json里增加iOS的白名单,即: "urlschemewhitelist" : "iosamap,baidumap,qqmap,comgooglemaps"
"ios" : {
"dSYMs" : false,
"urlschemewhitelist" : "iosamap,baidumap,qqmap,comgooglemaps",
"urltypes" : ""
},
集成插件
接口
import {
UTSOpenMap
} from '@/uni_modules/wrs-uts-openmap'
判断是否已经安装高德地图app,其他地图参考demo示例
var appInstall = true
if (this.isAndroid) {
appInstall = UTSOpenMap.isAppInstalled("com.autonavi.minimap")
} else {
appInstall = UTSOpenMap.isAppInstalled("iosamap://")
}
每个地图的调用请参考demo
- 直接拉起高德地图导航
// 输入终点,以用户当前位置为起点开始路线导航,提示用户每段行驶路线以到达目的地
var urlParams = "sourceApplication=" + this.sourceApplication + "&lat=" + this
.latitude + "&lon=" + this
.longitude + "&dev=1&style=2"
let params = {}
if (this.isAndroid) {
params.pkg = "com.autonavi.minimap"
params.data = "androidamap://navi?" + urlParams
} else {
params.url = "iosamap://navi?" + urlParams
}
UTSOpenMap.openOtherApp(params)
- 高德地图路线规划
// t = 0(驾车)= 1(公交)= 2(步行)= 3(骑行)= 4(火车)= 5(长途客车)
// 无起点,默认当前位置
var urlParams = "did=&dlat=" + this.latitude + "&dlon=" + this.longitude + "&dname=" + this
.destination +
"&dev=0&t=0"
// 有起点
// urlParams = "sid=&slat=39.92848272&slon=116.39560823&sname=A&did=&dlat="+this.latitude+"&dlon=" + this.longitude + "&dname="+this.destination+"&dev=0&t=0"
let params = {}
if (this.isAndroid) {
params.pkg = "com.autonavi.minimap"
params.data = "amapuri://route/plan/?" + urlParams
} else {
params.url = "iosamap://path?" + urlParams
}
UTSOpenMap.openOtherApp(params)
- 高德地图公交路线查询
var urlParams = "sourceApplication=softname&busname=445&city=010"
let params = {}
if (this.isAndroid) {
params.pkg = "com.autonavi.minimap"
params.data = "androidamap://bus?" + urlParams
} else {
params.url = "iosamap://bus?" + urlParams
}
UTSOpenMap.openOtherApp(params)
- 高德地图搜索地点
var urlParams = "sourceApplication=softname&keywords=kfc&dev=0"
// sourceApplication=softname&keywords=银行|加油站|电影院&lat1=36.1&lon1=116.1&lat2=36.2&lon2=116.2&dev=0
let params = {}
if (this.isAndroid) {
params.pkg = "com.autonavi.minimap"
params.data = "androidamap://poi?" + urlParams
} else {
params.url = "iosamap://poi?" + urlParams
}
UTSOpenMap.openOtherApp(params)