关于第三方地图
最近做地图导航功能,顾实现这四种地图导航功能,代码如下:
高德地图代码:
public static void openGaoDeMap(Context context, String name, String lat, String log) {try {if (MethodUtils.isAvilible(context, "com.autonavi.minimap")) {Intent intent = Intent.getIntent("androidamap://navi?sourceApplication=全球旅拍&poiname=" + name + "&lat=" + lat + "&lon=" + log + "&dev=0");context.startActivity(intent);} else {// ToastUtil.show(activity, "没有安装高德地图客户端");Log.e("GasStation", "没有安装高德地图客户端");}} catch (URISyntaxException e) {e.printStackTrace();}}- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
百度地图:
public static void openBaiduMap(Context context, String name, String lat, String log) {try {if (MethodUtils.isAvilible(context, "com.baidu.BaiduMap")) {Intent intent = Intent.getIntent("intent://map/navi?location=" + lat + "," + log +"&type=TIME&src=thirdapp.navi.hndist.sydt#Intent;scheme=bdapp;" +"package=com.baidu.BaiduMap;end");intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);context.startActivity(intent);// context.startActivity(intent);} else {// ToastUtil.show(activity, "没有安装高德地图客户端");RLog.e("没有安装百度地图客户端");}} catch (Exception e) {e.printStackTrace();}}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
腾讯地图:
public static void openTencentMap(Context context, String endPos, String endlat, String endlog, String startPos, String startlat, String startlog) {//com.tencent.map//qqmap://map/routeplan?type=drive&from=天坛南门&fromcoord=39.873145,116.413306&to=国家大剧院&tocoord=39.907380,116.388501try {if (MethodUtils.isAvilible(context, "com.tencent.map")) {Intent intent = Intent.getIntent("qqmap://map/routeplan?type=drive&from=" + startPos + "&fromcoord=" + startlat + "," + startlog + "&to=" + endPos + "&tocoord=" + endlat + "," + endlog + "");intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);context.startActivity(intent);// context.startActivity(intent);} else {// ToastUtil.show(activity, "没有安装高德地图客户端");RLog.e("没有安装腾讯地图客户端");}} catch (Exception e) {e.printStackTrace();}}- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
备注:腾讯原生地图不支持native导航方式,顾实现折中方式,驾车导航路径规划的方式。
Google地图:
public static void openGoogleMap(Context context, String name, String lat, String log) {if (isAvilible(context,"com.google.android.apps.maps")) {Uri gmmIntentUri = Uri.parse("google.navigation:q="+lat+","+log+", + Sydney +Australia");Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);mapIntent.setPackage("com.google.android.apps.maps");context.startActivity(mapIntent);}else {RLog.e("没有安装谷歌地图客户端");}}
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
