How to display a marker in Maps launched using a geographic URI Intent?

I have an application in which I want to show different locations (one at a time, selected using user input) by launching Google Maps with their specific geographical coordinates.

I am currently using this (with real lat. And long. Of course values):

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

This is exactly what I want, except that it does not show any indicator or marker for the specified point. These are only centers in this place.

Is there a way to add a marker or something else without using MapView?

+101
android android-intent google-maps android-maps
Oct 21 '10 at 17:15
source share
7 answers

Try the following:

 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 do not need the label, and he will choose one randomly based on the nearest street or other thing that, in his opinion, matters.

+242
Sep 13 '11 at 17:31
source share

The accepted answer is correct, unless there is an ampersand (&) on your label.

Considering a unified resource identifier for geographic locations (β€œgeographic” URIs) :

Section 5.1 states:

if the final URI should include the request component, add the "?" component separator to the end of the result, followed by the encoded query string.

Unfortunately for us, doing this will also elude '=', which is not what we want.

We must do this:

 String label = "Cinnamon & Toast"; String uriBegin = "geo:12,34"; String query = "12,34(" + label + ")"; String encodedQuery = Uri.encode(query); String uriString = uriBegin + "?q=" + encodedQuery; Uri uri = Uri.parse(uriString); Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri); startActivity(intent); 
+42
Mar 22 2018-12-22T00:
source share

There are many more options for launching a Google map using intent ...

  Double myLatitude = 44.433106; Double myLongitude = 26.103687; String labelLocation = "Jorgesys @ Bucharest"; 

one)

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<" + myLatitude + ">,<" + myLongitude + ">?q=<" + myLatitude + ">,<" + myLongitude + ">(" + labelLocation + ")")); startActivity(intent); 

2)

 String urlAddress = "http://maps.google.com/maps?q="+ myLatitude +"," + myLongitude +"("+ labelLocation + ")&iwloc=A&hl=es"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress)); startActivity(intent); 

3)

  String urlAddress = "http://maps.googleapis.com/maps/api/streetview?size=500x500&location=" + myLatitude + "," + myLongitude + "&fov=90&heading=235&pitch=10&sensor=false"; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(urlAddress)); startActivity(intent); 
+39
Feb 04 '14 at 16:29
source share

This line works well for me:

 String geoUriString="geo:"+lat+","+lon+"?q=("+head+")@"+lat+","+lon; Uri geoUri = Uri.parse(geoUriString); Log.e(TAG, "String: "+geoUriString); Intent mapCall = new Intent(Intent.ACTION_VIEW, geoUri); startActivity(mapCall); 
+5
Jan 27 '12 at 10:50
source share

Try adding (LocationMarkerName) to the geo: uri. For example, "geo:,? Z = 17 (LocationMarkerName)"

In Google Maps on Android, searching for 23.0980,30.6797 (NamedMarker) it seems that the center of the map is positioning a marker with the name NamedMarker in this position.

+2
Jan 17 '11 at 11:51
source share

I just confirmed the following snippet from @Kenton Price, which still works on Android 4.4 (KitKat):

 Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:<lat>,<long>?q=<lat>,<long>(Label+Name)")); startActivity(intent); 
+1
Jan 22 '14 at 6:13
source share

I used only MapView Overlays to draw markers on top of the map. If your view shows your map, perhaps you can simply draw a marker in the center of the screen, just like you draw any image in the view.

However, the marker will not be associated with the actual coordinates of the map, but if it is just a static view, then this may work.

0
Oct 21 2018-10-21
source share



All Articles