
每个人都实现多套地图网页调用高德地图导航,以在开发过程中实现导航功能. 导入SDK会增加APK的大小,而且很麻烦,但是您可以通过代码中的Intent直接调用百度地图客户端,高德地图客户端和Google地图客户端. 实现导航功能!事不宜迟,直接进入代码,很容易理解!
地图的官方URI API如下:
百度地图:

高德地图:
Google地图:
1. 确定是否安装地图

private boolean isInstallByread(String packageName) {
return new File("/data/data/" + packageName).exists();
}
2. 启用高德地图导航
/**
* 启动高德App进行导航
* sourceApplication 必填 第三方调用应用名称。如 amap
* poiname 非必填 POI 名称
* dev 必填 是否偏移(0:lat 和 lon 是已经加密后的,不需要国测加密; 1:需要国测加密)
* style 必填 导航方式(0 速度快; 1 费用少; 2 路程短; 3 不走高速;4 躲避拥堵;5 不走高速且避免收费;6 不走高速且躲避拥堵;7 躲避收费和拥堵;8 不走高速躲避收费和拥堵))
*/
private void openGaoDeNavi() {
StringBuffer stringBuffer = new StringBuffer("androidamap://navi?sourceApplication=")
.append("yitu8_driver").append("&lat=").append(lat)
.append("&lon=").append(lng)
.append("&dev=").append(1)
.append("&style=").append(0);
;
// if (!TextUtils.isEmpty(poiname)) {
// stringBuffer.append("&poiname=").append(poiname);
// }
Intent intent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(stringBuffer.toString()));
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setPackage("com.autonavi.minimap");
startActivity(intent);
}

3. 打开百度地图客户端进行导航
/**
* 打开百度地图导航客户端
* intent = Intent.getIntent("baidumap://map/navi?location=34.264642646862,108.95108518068&type=BLK&src=thirdapp.navi.you
* location 坐标点 location与query二者必须有一个,当有location时,忽略query
* query 搜索key 同上
* type 路线规划类型 BLK:躲避拥堵(自驾);TIME:最短时间(自驾);DIS:最短路程(自驾);FEE:少走高速(自驾);默认DIS
*/
private void openBaiduNavi() {
StringBuffer stringBuffer = new StringBuffer("baidumap://map/navi?location=")
.append(lat).append(",").append(lng).append("&type=TIME");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(stringBuffer.toString()));
intent.setPackage("com.baidu.BaiduMap");
startActivity(intent);
}
4. 打开移动浏览器Google Web进行导航
/**
* 打开google Web地图导航
*/
private void openWebGoogleNavi() {
StringBuffer stringBuffer = new StringBuffer("http://ditu.google.cn/maps?hl=zh&mrt=loc&q=").append(lat).append(",").append(lng);
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(stringBuffer.toString()));
startActivity(i);
}
5. 打开Google Maps客户端进行导航
/**
* 打开google地图客户端开始导航
* q:目的地
* mode:d驾车 默认
*/
private void openGoogleNavi() {
StringBuffer stringBuffer = new StringBuffer("google.navigation:q=").append(lat).append(",").append(lng).append("&mode=d");
Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse(stringBuffer.toString()));
i.setPackage("com.google.android.apps.maps");
startActivity(i);
}
6. 如果未安装地图网页调用高德地图导航,请去商店
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/shouji/article-264609-1.html
就是行贿的最典型代表啊
只要不是军用目的或者长期停靠
最新法规发布了