城阳工作端uniH5前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

171 lines
3.6 KiB

<template>
<view><button @click="button_bt">点击事件</button></view>
</template>
<script>
export default {
components: {
},
data() {
return {
};
},
methods: {
button_bt(){
this.toMapAPP("经度","纬度","地址")
},
toMapAPP(lat,lon,cityName) {
var url = '';
if (plus.os.name == 'Android') {
var hasBaiduMap = plus.runtime.isApplicationExist({
pname: 'com.baidu.BaiduMap',
action: 'baidumap://'
});
var hasAmap = plus.runtime.isApplicationExist({
pname: 'com.autonavi.minimap',
action: 'androidamap://'
});
var urlBaiduMap = 'baidumap://map/marker?location=' + lat + ',' + lon + '&title=' + cityName + '&src=婚梯';
var urlAmap = 'androidamap://viewMap?sourceApplication=婚梯&poiname=' + cityName + '&lat=' + lat + '&lon=' + lon +
'&dev=0';
// if (hasAmap && hasBaiduMap) {
plus.nativeUI.actionSheet({
title: '选择地图应用',
cancel: '取消',
buttons: [{
title: '百度地图'
}, {
title: '高德地图'
} ,{
title: '谷歌地图'
}]
}, function(e) {
switch (e.index) {
case 1:
plus.runtime.openURL(urlBaiduMap);
break;
case 2:
plus.runtime.openURL(urlAmap);
break;
case 3:
url = 'geo:' + lat + ',' + lon + '?q='+cityName; //如果是国外应用,应该优先使用这个,会启动google地图。这个接口不能统一坐标系,进入百度地图时会有偏差
plus.runtime.openURL(url);
break;
}
});
} else {
plus.nativeUI.actionSheet({
title: '选择地图应用',
cancel: '取消',
buttons: [{
title: 'Apple地图'
}, {
title: '高德地图'
} ,{
title: '谷歌地图'
}]
}, function(e) {
console.log('e.index: ' + e.index);
switch (e.index) {
case 1:
url = 'http://maps.apple.com/?q=%e6%95%b0%e5%ad%97%e5%a4%a9%e5%a0%82&ll=' + lat + ',' + lon +
'&spn=0.008766,0.019441';
break;
case 2:
url = 'baidumap://map/marker?location=' + lat + ',' + lon + '&title=' + cityName + '&src=婚梯';
break;
case 3:
url = 'iosamap://viewMap?sourceApplication=婚梯&poiname=' + cityName + '&lat=' + lat + '&lon=' + lon + '&dev=0';
break;
case 4:
url = 'geo:' + lat + ',' + lon + '?q='+cityName; //如果是国外应用,应该优先使用这个,会启动google地图。这个接口不能统一坐标系,进入百度地图时会有偏差
plus.runtime.openURL(url);
break;
default:
break;
}
if (url != '') {
plus.runtime.openURL(url, function(e) {
plus.nativeUI.alert('本机未安装指定的地图应用');
});
}
});
}
    }
},
};
</script>
<style></style>