//调用第三方导航
document.getElementById('ios_navigation').addEventListener('tap', ios_navigation);
function ios_navigation() {
plus.geolocation.getCurrentPosition(function(p) {
var origin_gps_x = p.coords.longitude;
var origin_gps_y = p.coords.latitude;
//百度转火星
var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
var x = analysis_cps_x - 0.0065;
var y = analysis_cps_y - 0.006;
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
var gg_lng = z * Math.cos(theta).toFixed(8);
var gg_lat = z * Math.sin(theta).toFixed(8);
// 设置目标位置坐标点和起始位置坐标点
var dst = new plus.maps.Point(gg_lng, gg_lat); // 导航目的地坐标
var src = new plus.maps.Point(origin_gps_x, origin_gps_y); // 导航起始地
plus.maps.openSysMap(dst, mpMc, src);
}, function(e) {
var origin_gps_x = null;
var origin_gps_y = null;
if (origin_gps_x == null && origin_gps_y == null) {
mui.toast("由于没有授权gps定位,当前位置无法获取");
}
});
// 调用系统地图显示
}
function androidMarket(pname) {
plus.runtime.openURL("market://details?id=" + pname);
}
function iosAppstore(url) {
plus.runtime.openURL("itms-apps://" + url);
}
document.getElementById('baidu_navigation').addEventListener('tap', function() {
//plus.runtime.openURL('baidumap://map/direction?destination='+analysis_cps_y+','+analysis_cps_x+'&mode=driving&coord_type=bd09&src=webapp.marker.yourCompanyName.yourAppName');
var url = null,
id = null,
f = null;
switch (plus.os.name) {
case "Android":
// 规范参考官方网站:http://developer.baidu.com/map/index.php?title=uri/api/android
url = 'baidumap://map/marker?location=' + analysis_cps_y + ',' + analysis_cps_x + '&title=' + mpMc + '&content=' + mp_dz + '&src=wenvip';
f = androidMarket;
id = "com.baidu.BaiduMap";
break;
case "iOS":
// 规范参考官方网站:http://developer.baidu.com/map/index.php?title=uri/api/ios
url = 'baidumap://map/navi?location=' + analysis_cps_y + ',' + analysis_cps_x + '&src=push&type=BLK&src=webapp.line.yourCompanyName.yourAppName';
f = iosAppstore;
id = "itunes.apple.com/cn/app/bai-du-de-tu-yu-yin-dao-hang/id452186370?mt=8";
break;
default:
return;
break;
}
plus.runtime.openURL(url, function(e) {
plus.nativeUI.confirm("检查到您未安装\"百度地图\",是否到商城搜索下载?", function(i) {
if (i.index == 0) {
f(id);
}
});
});
});
document.getElementById('gaode_navigation').addEventListener('tap', function() {
//百度转火星
var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
var x = analysis_cps_x - 0.0065;
var y = analysis_cps_y - 0.006;
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
var gg_lng = z * Math.cos(theta).toFixed(8);
var gg_lat = z * Math.sin(theta).toFixed(8);
var url = null,
id = null,
f = null;
switch (plus.os.name) {
case "Android":
// 规范参考官方网站:http://lbs.amap.com/api/uri-api/android-uri-explain/
url = 'androidamap://navi?sourceApplication=wenvip&poiname=' + mpMc + '&lat=' + gg_lat + '&lon=' + gg_lng + '&dev=0&style=2';
f = androidMarket;
id = "com.autonavi.minimap";
break;
case "iOS":
// 规范参考官方网站:http://lbs.amap.com/api/uri-api/ios-uri-explain/
url = 'iosamap://navi?sourceApplication=wenvip&backScheme=wenvip&lat=' + gg_lat + '&lon=' + gg_lng + '&dev=0&style=2';
f = iosAppstore;
id = "itunes.apple.com/cn/app/gao-tu-zhuan-ye-dao-hang-ban/id461703208?mt=8";
break;
default:
return;
break;
}
//IOS里,dev=0是关键,0代表gcj02坐标系,就是火星坐标, 没这个参数 高德是打不开的
plus.runtime.openURL(url, function(e) {
plus.nativeUI.confirm("检查到您未安装\"高德地图\",是否到商城搜索下载?", function(i) {
if (i.index == 0) {
f(id);
}
});
}, id);
});
翻了翻以前的代码,找到了关于导航选择地图的部分!仅供分享交流!
5 个评论
要回复文章请先登录或注册
独孤雄鹰
距离您98米
缺水的孩子
wzl16
s***@163.com