Launching Google Maps Directions via an intent on Android

后端 未结 15 1404
小鲜肉
小鲜肉 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:22

    if you know point A, point B (and whatever features or tracks in between) you can use a KML file along with your intent.

    String kmlWebAddress = "http://www.afischer-online.de/sos/AFTrack/tracks/e1/01.24.Soltau2Wietzendorf.kml";
    String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%s",kmlWebAddress);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
    startActivity(intent);
    

    for more info, see this SO answer

    NOTE: this example uses a sample file that (as of mar13) is still online. if it has gone offline, find a kml file online and change your url

提交回复
热议问题