问题
I'm working in Android Studio with MapsActivity. Everything works fine, but how do I disable the map controls that show up on top of the Google map?
Here is my code:
public class MapsActivity extends FragmentActivity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
}
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
}
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
if (mMap != null) {
setUpMap();
}
}
}
private void setUpMap() {
mMap.addMarker(new MarkerOptions()
.position(new LatLng(46.066185, 19.674654))
.title("Novo naselje okretnica ")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.bluebus2)));
}
Check out the image, to see what I'm talking about.
So there is the problem, I don't want those map controls. Please help me figure out how to disable this. Thx :)
回答1:
Thank you @Coeffect! It works!
public class MapsActivity extends FragmentActivity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
setUpMapIfNeeded();
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMapToolbarEnabled(false);
}
回答2:
From https://developers.google.com/maps/documentation/android/interactivity#map_toolbar
By default, a toolbar appears at the bottom right of the map when a user taps a marker. The toolbar gives the user quick access to the Google Maps mobile app.
You can enable and disable the toolbar by calling UiSettings.setMapToolbarEnabled(boolean).
来源:https://stackoverflow.com/questions/30655421/google-maps-android-studio-how-disable-the-map-controls