Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Google Maps realign north button

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.

enter image description here

Thanks!

like image 563
Bernard Avatar asked Aug 09 '17 15:08

Bernard


People also ask

How do I turn off north on Google Maps?

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”.

How do I turn off the compass on Google Maps?

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.

Is Google Maps automatically oriented north?

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.


1 Answers

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));
    }
}
like image 165
xomena Avatar answered Oct 30 '22 07:10

xomena