judgeHasExistNavignation() {
let navAppParam = [{
pname: 'com.baidu.BaiduMap',
action: 'baidumap://'
},
{
pname: 'com.autonavi.minimap',
action: 'iosamap://'
},
{
pname: 'com.tencent.map',
action: 'tencentmap://'
},
];
return navAppParam.some(param => {
return plus.runtime.isApplicationExist(param);
})
},
getPosition() {
let that = this;
return new Promise(resolve => {
uni.getLocation({
type: 'gcj02',
geocode: true,
success: function(res) {
let {
latitude,
longitude
} = res
that.curSysPosition.latitude = latitude;
that.curSysPosition.longitude = longitude;
resolve();
}
});
})
},
async handleOpenNavigation() {
const lat = this.info.y;
const lng = this.info.x;
const address = '目的地';
if (!this.judgeHasExistNavignation()) {
return this.$showToast("该设备上不存在第三方导航APP");
}
await this.getPosition();
let {
latitude,
longitude
} = this.curSysPosition;
let tLngLat = new plus.maps.Point(lng, lat);
let oLngLat = new plus.maps.Point(longitude, latitude);
plus.maps.openSysMap(tLngLat, address, oLngLat);
},
toNearbyStore() {
var url = '';
const address = '去到这里';
const latitude = this.info.y;
const longitude = this.info.x;
url = 'geo:' + latitude + ',' + longitude + '?q=' + encodeURIComponent(address);
if (uni.getSystemInfoSync().platform == 'android') {
plus.runtime.openURL(url);
} else {
plus.nativeUI.actionSheet({
title: "选择地图应用",
cancel: "取消",
buttons: [{
title: "Apple地图"
}, {
title: "百度地图"
}, {
title: "高德地图"
}, {
title: "google地图"
}]
}, function(e) {
console.log("e.index: " + e.index);
switch (e.index) {
case 1:
url =
`http://maps.apple.com/?q=${encodeURIComponent(address)}&ll=${latitude},${longitude}&spn=0.008766,0.019441`
break;
case 2:
url = `baidumap://map/marker?location=${latitude},${longitude}&title=DCloud&src=Hello%20uni-app`;
break;
case 3:
url =
`iosamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=${latitude}&lon=${longitude}&dev=0`;
break;
case 4:
url = `comgooglemaps://?q=${encodeURIComponent(address)}¢er=${latitude},${longitude}`;
break;
plus.runtime.openURL(url, function(e) {
plus.nativeUI.alert("未安装此地图");
});
}
})
}
},
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106