Android – How to show a marker in Maps launched by geo URI Intent

androidandroid-intentandroid-mapsgoogle maps

I have a application where I want to show different locations (one at the time, picked by user input) by launching Google Maps with their specific geo coordinates.

I'm currently using this (with real lat. and long. values of course):

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?z=17"));
startActivity(intent);

It's quite exactly what I want, except that it doesn't show any indicator or marker for the specified point. It only centers at it's location.

Is there some way to get the marker or something else included without using a MapView?

Best Answer

Try this:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)"));
startActivity(intent);

You can omit (Label+Name) if you don't want a label, and it will choose one randomly based on the nearest street or other thing it thinks relevant.

Related Topic