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

来源:互联网 发布:seo 教程 编辑:程序博客网 时间:2024/05/17 08:30




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(), "检测到你还没有安装地图");
}


0 0
原创粉丝点击