Issue
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!
Solution
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));
}
}
Answered By - xomena
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.