Warm tip: This article is reproduced from serverfault.com, please click

how to Intent to particular location in google maps with marker on it?

发布于 2020-11-28 10:57:31

I'm creating a tour app with Firebase as a backend. I need to know how to intent aparticular location with marker on it?

Intent i = new Intent (Intent.ACION_VIEW) like this, or is there any other method to do with marker on it ?

Questioner
MadhanMohan
Viewed
0
Mohammed Alaa 2020-11-28 19:24:28

Try this sample for launching google maps with specific Lat & Lng

public void gotToLocation(String markerName,Float latitude, Float longitude ) {
    String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%f,%f(%s)", latitude,longitude,markerName);
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));;
    mapIntent.setPackage("com.google.android.apps.maps");
    if (mapIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        startActivity(mapIntent);
    }
}

then call it like this

gotToLocation("MyLocation",34.99,-106.61);