Launching Google Maps Directions via an intent on Android

后端 未结 15 1433
小鲜肉
小鲜肉 2020-11-22 03:46

My app needs to show Google Maps directions from A to B, but I don\'t want to put the Google Maps into my application - instead, I want to launch it using an Intent. Is this

15条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 04:11

    For multiple way points, following can be used as well.

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
        Uri.parse("https://www.google.com/maps/dir/48.8276261,2.3350114/48.8476794,2.340595/48.8550395,2.300022/48.8417122,2.3028844"));
    startActivity(intent);
    

    First set of coordinates are your starting location. All of the next are way points, plotted route goes through.

    Just keep adding way points by concating "/latitude,longitude" at the end. There is apparently a limit of 23 way points according to google docs. Not sure if that applies to Android too.

提交回复
热议问题