I have the url https://www.google.com/maps/@41.3825581,2.1704375,16z
that positions Barcelona on the map, but I find that the address pointer does not come out, it only centers the map.
On my device I have several map apps:
- Cytymapper
- MAPS.ME
- Google Maps
- Google Earth
The code I have to launch the Intent
:
Uri uri = Uri.parse("https://www.google.com/maps/@41.3825581,2.1704375,16z");
if (URLUtil.isValidUrl(uri.toString())) {
startActivity( new Intent(Intent.ACTION_VIEW, uri));
}
I get a ActionList
to choose Maps
or Chrome
, if Maps
I click on the application opens maps
, but it does not show me the position with an indicator, it focuses on landmark and point.
If I indicate that it opens with chrome
, another appears ActionList
, with the other map applications.
My doubts are:
- How do I launch a
Intent
specific so that it can be opened with the Maps Apps? - How can I display the position marker within the map?
Fixed:
To display a location with marker and label
geo:<lat>,<lon>?z=<zoom>&q=<lat>,<lon>(<label>)
To show the location of Barcelona
geo:41.3825581,2.1704375?z=16&q=41.3825581,2.1704375(Barcelona)
To show the ActionList
output of all compatible applications to position a location
Uri uri = Uri.parse("geo:41.3825581,2.1704375?z=16&q=41.3825581,2.1704375(Barcelona)");
startActivity( new Intent(Intent.ACTION_VIEW, uri));
If you want to send the position directly to the Google Maps application
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:41.3825581,2.1704375?z=16&q=41.3825581,2.1704375(Barcelona)"));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
According to this answer on SO in English:
The form is this:
You can do it like this:
The xxxx represent latitude and longitude and 14.0f the zoom level.
https://www.google.com/maps/@41.3825581,2.1704375,16z
How can I display the position marker within the map?
I don't know if there is a better way to do what you ask, but if I understand your question you can try some of the following examples, if it is what you are looking for you could implement it in some way in your app, if you can't get the coordinates in the following Act , I could pass them inside the Intent and retrieve them there.
How do I launch a specific Intent so that it can be opened by Maps Apps?
About the part that says how to open an app with an Intent, I don't know if this is what you mean: