toDaohang(point){ let that = this //打开高德 Dialog.confirm({ title: '', message: '打开高德地图', }) .then(() => { let str = [] if(point!=''){ str = point.split('(')[1].replace(')','').split(' ') let url = '' if(that.fromLon != '' && that.fromLat != ''){
url = `https://uri.amap.com/navigation?from=${that.fromLon},${that.fromLat},我的位置&to=${str[0]},${str[1]},目的地,1&mode=car&policy=0&src=mypage&coordinate=gaode&callnative=1` }else{ url = `https://uri.amap.com/navigation?to=${str[0]|| ''},${str[1]},目的地,1&mode=car&policy=0&src=mypage&coordinate=gaode&callnative=1` } window.open(url) }else{ Toast('未设置位置坐标'); } }) .catch(() => { // on cancel }); },
that.fromLon 和that.fromLat是进入页面获取用户当前的经纬度,作为导航中我的位置
callnative: 高德地图WEB版链接的callnative参数也具有唤起APP的功能,所以可以利用WEB版间接唤起APP,openAMap方法修改如下:
`https://uri.amap.com/navigation?from=${result.position.lng},${result.position.lat},我的位置&to=${lng},${lat},${address}&mode=car&policy=1&src=com.mzwu.www&callnative=1`
//获取坐标 getLocation() { var options = { enableHighAccuracy: true, maximumAge: 1000, }; if (navigator.geolocation) { //浏览器支持geolocation navigator.geolocation.getCurrentPosition( this.onSuccess, this.onError, options ); } else { //浏览器不支持geolocation // $("#div").append("<p>您的浏览器不支持地理位置定位</p>"); } }, onSuccess(position) { var longitude = position.coords.longitude; var latitude = position.coords.latitude;this.fromLon = longitude this.fromLat = latitude }, one rror(error) { console.log(1) switch (error.code) { case 1: console.log("位置服务被拒绝"); break; case 2: console.log("暂时获取不到位置信息"); break; case 3: console.log("获取信息超时"); break; case 4: console.log("未知错误"); break; } },
标签:callnative,网页,log,微信,str,position,console,高德 From: https://www.cnblogs.com/xhrr/p/17884709.html