MadhanMohan
MadhanMohan

Reputation: 95

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

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 ?

Upvotes: 0

Views: 669

Answers (2)

Masoud Badrmiran
Masoud Badrmiran

Reputation: 451

Hi you can use google documentation. Google Map

Uri gmmIntentUri = Uri.parse("geo:0,0?q=-33.8666,151.1957(Google+Sydney)");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

Above example displays a label at the location of Google's Sydney office

Upvotes: 0

Mohammed Alaa
Mohammed Alaa

Reputation: 3320

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);

Upvotes: 1

Related Questions