How to hide "Navigation" and "GPS Pointer" buttons when I click the marker on the android google map

AndroidGoogle MapsGoogle Maps-Android-Api-2Marker

Android Problem Overview


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

enter image description here

Android Solutions


Solution 1 - Android

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 with Java:

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

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

mMap.getUiSettings().setZoomControlsEnabled(false);

In Kotlin you can use property access syntax:

mMap.uiSettings.isMapToolbarEnabled = false
mMap.uiSettings.isZoomControlsEnabled = false

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTim YuView Question on Stackoverflow
Solution 1 - AndroidDaniel NugentView Answer on Stackoverflow