如何隐藏“导航”和“全球定位系统指针”按钮时,我点击标记的机器人谷歌地图

当我点击谷歌地图上的标记,“导航”和“ GPS 指针”按钮出来。在 android 开发中,如何以编程方式隐藏这两个导航按钮?

enter image description here

35651 次浏览

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