11

I have a map in my android application with several markers. When I click on any of the markers the info window appears and also a directions button on the bottom right hand side corner just like the picture below shows.

Google Maps

The problem is that I also open the info window programmatically based on user inputs within the app. I do this using marker.showInfoWindow() but this way it doesn't show the directions button. I have googled around and not found anyone with a similar issue, was hoping there was a way for the button to appear and if so how?

Community
  • 1
  • 1
Daniel Julio
  • 1,463
  • 3
  • 14
  • 23
  • Possible duplicate of [Display toolbar for Google Maps marker automatically](http://stackoverflow.com/questions/27690711/display-toolbar-for-google-maps-marker-automatically) – Jeremy Oct 29 '15 at 21:54
  • 2
    Did you ever solve this? I have the same issue... showInfoWindow() does not cause the Google buttons to appear. I have tried setMapToolbarEnabled(true); and it does not work. – TriGuy Dec 10 '16 at 20:28

2 Answers2

5

You need to do as follows:

GoogleMap myMap;
myMap.getUiSettings().setMapToolbarEnabled(true);

You can get all sample project code on my github here and try yourself:) Just long click on map to set up a marker, click it, show the infoWindow, and finally, it will show the button.

enter image description here

bjiang
  • 6,068
  • 2
  • 22
  • 35
  • 4
    But I still need to click the marker for the directions button to display? I want the button to appear when I show the info window programmatically, not when I show the info window because I clicked on the marker. – Daniel Julio May 28 '15 at 16:23
  • Is it possible to move these buttons to the left side of the screen instead of default right side? – IgorGanapolsky Aug 19 '15 at 02:31
  • 1
    @IgorGanapolsky From [this](http://stackoverflow.com/a/28688624/4186942) I think the answer is no.. – bjiang Aug 19 '15 at 05:18
  • @bijang Actually, you can use `padding` property on the map, and that will move the buttons over. The problem with that approach is - it will move ALL buttons on the map. – IgorGanapolsky Aug 19 '15 at 13:08
  • @IgorGanapolsky yeah I know that padding thing. However, there is no default method for moving those button I think – bjiang Aug 19 '15 at 17:45
  • @Daniel Julio, you can use the following MapFragment properties: map:mapType="normal" and map:liteMode="true. In LiteMode the toolbar shows by default without the need of clicking. You lose the possibility to zoom in and out though. – Kalin Krastev Jul 10 '18 at 09:43
3

For the button group you have , you can disable it using the setMapToolbarEnabled() method in UISettings.

Code example to disable the two buttons:

//Disable Map Toolbar:
mMap.getUiSettings().setMapToolbarEnabled(false);