首页 > 系统 > Android > 正文

Android调用google地图生成路线图实现代码

2019-10-24 21:05:56
字体:
来源:转载
供稿:网友
Android程序调用本机google地图并且传递起始和终点位置生成路线图,有需要的朋有可以参考下,或许本文对你有所帮助,好了话不多说,看代码
 
Android程序调用本机googlemap,传递起始和终点位置,生成路线图
复制代码代码如下:

if (wodeweizhiPoint != null) { 
if (wodeweizhiPoint.getLatitudeE6() != 0) { 
float chufajingdu = (float) (wodeweizhiPoint.getLongitudeE6() / 1E6); 
float chufaweidu = (float) (wodeweizhiPoint.getLatitudeE6() / 1E6); 
float daodajingdu = (float) (AppConstant.PointZuoBiao.liangxiangDaoHangPoint.getLongitudeE6() / 1E6); 
float daodaweidu = (float) (AppConstant.PointZuoBiao.liangxiangDaoHangPoint.getLatitudeE6() / 1E6); 
// 标记一个点 
// Intent i = new 
// Intent(Intent.ACTION_VIEW,Uri.parse("http://ditu.google.cn/maps?hl=zh&mrt=loc&q=31.249351,121.45905")); 

// 从哪到哪的路线 
Intent i = new Intent(Intent.ACTION_VIEW,Uri.parse("http://ditu.google.cn/maps?f=d&source=s_d&saddr=" 
+ chufaweidu 
+ "," 
+ chufajingdu 
+ "&daddr=" 
+ daodaweidu 
+ "," 
+ daodajingdu + "&hl=zh")); 
//如果强制使用googlemap地图客户端打开,就加下面两句 
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK& Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); 
i.setClassName("com.google.android.apps.maps","com.google.android.maps.MapsActivity"); 
startActivity(i); 

} else { 
AlertUtils.ToastAlert(mContext, “由于无法获取到您的位置,所以暂时无法提供导航”); 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表