Android調(diào)用google地圖生成路線圖實(shí)現(xiàn)代碼
更新時(shí)間:2013年02月02日 17:31:08 作者:
Android程序調(diào)用本機(jī)google地圖并且傳遞起始和終點(diǎn)位置生成路線圖,有需要的朋有可以參考下,或許本文對你有所幫助,好了話不多說,看代碼
Android程序調(diào)用本機(jī)googlemap,傳遞起始和終點(diǎn)位置,生成路線圖
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);
// 標(biāo)記一個(gè)點(diǎn)
// 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"));
//如果強(qiáng)制使用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, “由于無法獲取到您的位置,所以暫時(shí)無法提供導(dǎo)航”);
}
復(fù)制代碼 代碼如下:
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);
// 標(biāo)記一個(gè)點(diǎn)
// 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"));
//如果強(qiáng)制使用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, “由于無法獲取到您的位置,所以暫時(shí)無法提供導(dǎo)航”);
}
您可能感興趣的文章:
- Android中利用App實(shí)現(xiàn)消息推送機(jī)制的代碼
- Android開發(fā)筆記之:消息循環(huán)與Looper的詳解
- android的消息處理機(jī)制(圖文+源碼分析)—Looper/Handler/Message
- Android中使用WebSocket實(shí)現(xiàn)群聊和消息推送功能(不使用WebView)
- Android中通過Notification&NotificationManager實(shí)現(xiàn)消息通知
- Android消息處理機(jī)制Looper和Handler詳解
- android開發(fā)教程之使用looper處理消息隊(duì)列
- Android中使用socket通信實(shí)現(xiàn)消息推送的方法詳解
- Android頂欄定時(shí)推送消息
- android使用NotificationListenerService監(jiān)聽通知欄消息
- 深入淺析Android消息機(jī)制
- android通過google api獲取天氣信息示例
- Android編程實(shí)現(xiàn)google消息通知功能示例
相關(guān)文章
解決Android橫豎屏切換數(shù)據(jù)丟失問題的方法
這篇文章主要為大家詳細(xì)介紹了Android橫豎屏切換數(shù)據(jù)丟失問題的解決方法,感興趣的小伙伴們可以參考一下2016-05-05
android?studio項(xiàng)目:綁定服務(wù)和線程實(shí)現(xiàn)計(jì)時(shí)器
這篇文章主要介紹了android?studio項(xiàng)目:綁定服務(wù)和線程實(shí)現(xiàn)計(jì)時(shí)器,完成一個(gè)秒表,具備啟停功能,通過綁定服務(wù)實(shí)現(xiàn)功能,通過Thread+handler更新界面,需要的朋友可以參考一下2021-12-12
關(guān)于Android Studio安裝完后activity_main.xml前幾行報(bào)錯(cuò)的解決建議
這篇文章主要介紹了關(guān)于Android Studio安裝完后activity_main.xml前幾行報(bào)錯(cuò)的解決建議,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-03-03
Android WebView使用方法詳解 附j(luò)s交互調(diào)用方法
這篇文章主要為大家詳細(xì)介紹了Android WebView使用方法詳解,文中附j(luò)s交互調(diào)用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-05-05
Android之禁止ViewPager滑動(dòng)實(shí)現(xiàn)實(shí)例
這篇文章主要介紹了Android之禁止ViewPager滑動(dòng)實(shí)現(xiàn)實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-05-05
android中一些特殊字符(如:←↑→↓等箭頭符號(hào))的Unicode碼值
這篇文章主要介紹了android中一些特殊字符(如:←↑→↓等箭頭符號(hào))的Unicode碼值,需要的朋友可以參考下2017-03-03

