I have a marker and when I open the map it shows the marker. When I click on it it shows the title and a toolbar which includes two buttons on the bottom right of the map which let me launch intents to navigate to the marker or show it in google maps. I would like to have these displayed automatically when the map is opened rather than having the user to click on the marker.
Like this :-) ... I can't seem to work out how to do this.
I have tried:
// create marker
MarkerOptions marker = new MarkerOptions().position(
new LatLng(latitude, longitude)).title("title");
// adding marker
googleMap.addMarker(marker).showInfoWindow();
googleMap.getUiSettings().setMapToolbarEnabled(true);
But this just shows the marker title and a button on the top right to go to my location not the two toolbar intent buttons on the bottom right.
Like this :-( ... I'm a bit stuck any ideas?
I added a feature request here: http://code.google.com/p/gmaps-api-issues/issues/detail?id=7652
For the toolbar you have outlined in red, you can disable it using the setMapToolbarEnabled() method in UISettings
From the documentation:
Code example to disable the two buttons:
Just in case you were also wondering about the zoom buttons, you can disable them like this:
The overlay that appears when a marker is clicked, is created and destroyed on-the-spot implicitly. You can't manually show that (yet).
If you must have this functionality, you can create an overlay over your map with 2
ImageViews
, and call appropriate intents when they're clicked:Note: you need to change the coordinates based on Marker's
getPosition()
and the user's location.Now to hide the default overlay, all you need to do is return true in the
OnMarkerClickListener
. Although you'll lose the ability to showInfoWindows
and center camera on the marker, you can imitate that simply enough:Quoting the doc:
Seeems like there is no way to persist the toolbar in your case since its an interactive map. You might want to try using lite-mode if that is a requirement: https://developers.google.com/maps/documentation/android/lite
Also looking at your code:
The very last line:
googleMap.getUiSettings().setMapToolbarEnabled(true);
is redundant unless you are explicitly setting it to false beforehand. The doc states:The link: https://developer.android.com/reference/com/google/android/gms/maps/UiSettings.html#setMapToolbarEnabled(boolean)
Hope this helps.
I had a similar issue..... if you are okay with not letting the user browse in the map and just focus on your marker, you can use lite-mode map.... Quote from documentation
Again from docs
Show a DialogFragment instead of the info window and handle everything in it.
OR
use the marker clicks to turn an overlay on/off using a facsimile of a Google map button