How to hide “Navigation” and “GPS Pointer” buttons

2019-01-10 19:40发布

问题:

When I click the marker on the google map, "Navigation" and "GPS Pointer" buttons come out.How can I hide those two buttons programatically in android development?

回答1:

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

From the documentation:

Sets the preference for whether the Map Toolbar should be enabled or disabled. If enabled, users will see a bar with various context-dependent actions, including 'open this map in the Google Maps app' and 'find directions to the highlighted marker in the Google Maps app'.

Code example to disable the two buttons:

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

Just in case you were also wondering about the zoom buttons, you can disable them like this:

mMap.getUiSettings().setZoomControlsEnabled(false);