Hi I would like to know how to disable the north align compass button in the top left corner of Google Maps. I linked an image to show what I am talking about. I have found out how to disable other UI components but I find nothing about disabling this button. I am using android studio.
Thanks!
Inside settings scroll down again near the bottom to “Navigation Settings”. Now just turn on the option (flip the switch) labeled “Keep map north up”.
Finding North Using Google Maps To do this, tap the compass icon in the top-right corner of the Google Maps map view. Your map position will move, with the icon updating to show that you're pointing north. After a few seconds, the compass icon will disappear from the map view.
The orientation of Google Maps is always the same when you're browsing on a computer. North is on the top of the map, and south is on the bottom. The left will always be west, and the right is always east. Anything directly above the location you're browsing is always to the location's north.
The UiSettings
object of maps has a setCompassEnabled()
method that you can use to enable or disable the realign north button.
https://developers.google.com/android/reference/com/google/android/gms/maps/UiSettings
The simple activity that shows how to do it
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));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With