您的位置:首页 > 其它

关于导航的使用(感恩我的领导阿密,没有收版权费)

2016-01-13 14:32 162 查看
if (AppUtils.checkPackage(getApplicationContext(),
"com.autonavi.minimap")) {
// 移动APP调起Android高德地图方式
Intent intent = new Intent(
"android.intent.action.VIEW",
android.net.Uri
.parse("androidamap://navi?sourceApplication=appname&poiname="
+ toLatLng.getLanName()
+ "&lat="
+ toLatLng.getLatitude()
+ "&lon="
+ toLatLng.getLongitude()
+ "&dev=0&style=2"));
intent.setPackage("com.autonavi.minimap");
context.startActivity(intent);

} else if (AppUtils.checkPackage(getApplicationContext(),
"com.baidu.BaiduMap")) {
// 移动APP调起Android百度地图方式
Intent intent = null;
try {
intent = Intent
.getIntent("intent://map/direction?origin=latlng:"
+ fromLatLng.getLatitude()
+ ","
+ fromLatLng.getLongitude()
+ "|name:"
+ fromLatLng.getLanName()
+ "&destination=latlng:"
+ toLatLng.getLatitude()
+ ","
+ toLatLng.getLongitude()
+ "|name:"
+ toLatLng.getLanName()
+ "&mode=driving&coord_type=gcj02&src=依威能源|E充站#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end");
context.startActivity(intent); // 启动调用
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

} else {
// 移动APP调起高德网页地图方式
String urlStr = "http://m.amap.com/?from="
+ fromLatLng.getLatitude() + ","
+ fromLatLng.getLongitude() + "(from)&to="
+ toLatLng.getLatitude() + "," + toLatLng.getLongitude()
+ "(to)&type=0&opt=0&dev=0";

Uri uri = Uri.parse(urlStr);
Intent it = new Intent(Intent.ACTION_VIEW, uri);
context.startActivity(it);

// T.showLong(getActivity(), "检测到你还没有安装地图");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: