Android调用本机地图APP

官方文档地址

高德:http://lbs.amap.com/api/amap-mobile/guide/android/route
百度:http://lbsyun.baidu.com/index.php?title=uri/api/android
腾讯:http://lbs.qq.com/uri_v1/guide-route.html
谷歌:https://developers.google.com/maps/documentation/android-api/intents

地图应用包名

根据包名可查询是否安装了该应用
高德:com.autonavi.minimap
百度:com.baidu.BaiduMap
腾讯:com.tencent.map

代码示例

没有传入起点坐标,则默认定位当前位置为起点
调起百度导航:

intent = new Intent();
intent.setData(Uri.parse("baidumap://map/direction?" +                  
"destination=latlng:" + latitude + "," + longtitude + "|name:目的地" +"&mode=driving"));
startActivity(intent);

调起高德导航:

intent = new Intent();
intent.setPackage("com.autonavi.minimap");
intent.setAction("android.intent.action.VIEW");
intent.addCategory("android.intent.category.DEFAULT");
LatLng newEnd = convertBaiduToGPS(new LatLng(latitude, longtitude));//转换坐标系
intent.setData(Uri.parse("androidamap://route?sourceApplication=艾亚科技&dlat=" + newEnd.latitude + "&dlon=" + newEnd.longitude + "&dname=目的地" + "&dev=0&t=0"));
startActivity(intent);

调起腾讯导航:

intent = new Intent();
LatLng newEnd = convertBaiduToGPS(new LatLng(latitude, longtitude));//转换坐标系
intent.setData(Uri.parse("qqmap://map/routeplan?type=walk&to=目的地&tocoord=" + newEnd.latitude +"," + newEnd.longitude + "&policy=1&referer=myapp"));
startActivity(intent);

具体参数含义,上述官网中有详细注解。

猜你喜欢

转载自blog.csdn.net/wernerzeiss/article/details/78434588