Android calls Google Maps to generate roadmap implementation code _android

Source: Internet
Author: User
The Android program calls native GoogleMap, passing the start and end positions, generating a roadmap
Copy Code code as follows:

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);
Mark a Point
Intent i = new
Intent (Intent.action_view,uri.parse ("http://ditu.google.cn/maps?hl=zh&mrt=loc&q=31.249351,121.45905") ));

The route from where to where
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"));
If the GoogleMap map client is forced to open, add the following two sentences
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, "cannot provide navigation" because it cannot get to your location);
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.