4

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 :)

Bruce
  • 8,202
  • 6
  • 37
  • 49
  • 1
    http://stackoverflow.com/questions/30430664/how-to-hide-navigation-and-gps-pointer-buttons-when-i-click-the-marker-on-th/30431024#30431024 – Daniel Nugent Jun 05 '15 at 01:25

2 Answers2

4

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);
}
1

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

Community
  • 1
  • 1
Coeffect
  • 8,772
  • 2
  • 27
  • 42