Show Routes button on a Google Map when the info window is open programmatically

I have a map in an Android app with several markers. When I click on any of the markers, an information window appears, as well as a direction button in the lower right corner, as shown in the figure below.

Google maps

The problem is that I also open the info window programmatically based on user inputs in the application. I do this with marker.showInfoWindow (), but this way it does not display the directions button. I googled around and did not find anyone with a similar problem, hoped there was a way for the button to appear, and if so, how?

+6
source share
2 answers

You need to do the following:

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

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

enter image description here

+3
source

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

Sample code to disable two buttons:

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

Source: https://habr.com/ru/post/988102/


All Articles