您好我想知道如何禁用Google地图左上角的北对齐罗盘按钮。我链接了一个图像,以显示我在说什么。我已经找到了如何禁用其他UI组件,但我找不到关于禁用此按钮的任何信息。我正在使用android studio。
谢谢!
答案 0 :(得分:4)
地图的UiSettings
对象有setCompassEnabled()
方法,可用于启用或禁用重新调整北按钮。
https://developers.google.com/android/reference/com/google/android/gms/maps/UiSettings
显示如何操作的简单活动
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
mMap.getUiSettings().setCompassEnabled(false);
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}