关于App打开高德和百度地图导航的代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于App打开高德和百度地图导航的代码相关的知识,希望对你有一定的参考价值。
参考技术A 高德调起app传送门:http://lbs.amap.com/api/amap-mobile/summary/百度调起app传送门:http://lbsyun.baidu.com/index.php?title=uri/api/android
百度网页版传送门:http://lbsyun.baidu.com/index.php?title=uri/api/web
百度逆地址编码:
uni.request(
url: 'http://api.map.baidu.com/geocoding/v3/?address='+ name +'&output=json&ak=6HwKBtjU7LkA9xtOkoKVc8AUB8Fzyk8d',
header:
'content-type': "application/x-www-form-urlencoded"
,
success: (res) =>
console.log(res.data);
this.baiDuApiZuoBiao(res.data.result.location.lat,res.data.result.location.lng,name);
,
fail(err)
console.log(err);
);
高德逆地址编码
uni.request(
url: 'https://restapi.amap.com/v3/geocode/geo?address='+ name +'&output=JSON&key=74b7c3bfe5d54c46d0792bbd69ac3aa2',
header:
'content-type': "application/x-www-form-urlencoded"
,
success: (res) =>
console.log(res.data);
var join = res.data.geocodes[0].location.split(",");
console.log(join);
console.log("地理编码==" + JSON.stringify(res));
this.gaoDeApiZuoBiao(join[1],join[0],name);
,
fail(err)
);
打开百度地图App
var url = `baidumap://map/navi?location=$latitude,$longitude&title=$name&coord_type=gcj02&src=andr.baidu.openAPIdemo`;
打开高德地图App
let url = `androidamap://navi?sourceApplication=appname&poiname=$name&lat=$latitude&lon=$longitude&dev=0`;
plus.runtime.openURL(url , function(e) );
iOS打开百度地图高德地图导航
- BOOL hasBaiduMap = NO;
- BOOL hasGaodeMap = NO;
- if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"baidumap://map/"]]){
- hasBaiduMap = YES;
- }
- if ([[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:@"iosamap://"]]){
- hasGaodeMap = YES;
- }
- if ([@"使用百度地图导航" isEqualToString:title])
- {
- NSString *urlString = [[NSString stringWithFormat:@"baidumap://map/direction?origin=latlng:%f,%f|name:我的位置&destination=latlng:%f,%f|name:终点&mode=driving",currentLat, currentLon,_shopLat,_shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] ;
- [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
- }
- else if ([@"使用高德地图导航" isEqualToString:title])
- {
- NSString *urlString = [[NSString stringWithFormat:@"iosamap://navi?sourceApplication=%@&backScheme=%@&poiname=%@&lat=%f&lon=%f&dev=1&style=2",@"app name", yourscheme, @"终点", _shopLat, _shopLon] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- [[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlString]];
- }
以上是关于关于App打开高德和百度地图导航的代码的主要内容,如果未能解决你的问题,请参考以下文章