From my app I would like to start the Google Maps App with a provided location and a marker. The marker should indicate, that there is something on that given location.
For now, I have the following code, which starts with an Intent the Google Maps App with the provided location (51.49234, 7.43045).
startActivity(
new Intent(
android.content.Intent.ACTION_VIEW,
Uri.parse("geo:51.49234,7.43045")));
When the Google Maps App starts, it looks like the following:
No marker is shown. I would like, that the Google Maps App would show a marker on that position, which is given through the Intent. Is there any "hidden" Intent URI's which I can use to show a marker within the Google Maps App?
Thanks in advance.
@Rajiv M. pointed me to the idea of querying the surroundings with the given location.
So, the solution is: Query the surroundings of your given location with your given location as the parameter. The URI looks like:
geo:51.49234,7.43045?q=51.49234,7.43045
Google Maps will show the query-result as the street name:
Kind of a hack, but it seems to work well.
Why you should not use 0,0 as the map location
geo:0,0?q=51.49234,7.43045
When you start Google Maps App with the provided map location point 0,0 , Google Maps App will start searching for your current device position. And this takes time. In some cases, when GPS signal is not provided, way too much. Until then the Google Maps App will start searching for your query 51.49234,7.43045.
Try starting Google Maps using the same intent, but with a URI of the format:
geo:34.067214,-118.349332?q=410+Hauser+Boulevard,+Los+Angeles,+CA
i.e. geo:0,0?q=street+address
The application should then actually show a point at that address. If you do not have the address, you may have to use a service to translate it to an address for this to work.
-
The other option is to embed a MapView in your application and add a marker within that. A tutorial for using MapViews / Markers with-in your application can be found at http://mobiforge.com/developing/story/using-google-maps-android.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With