Search code examples
androidgoogle-mapsgoogle-maps-markersgoogle-maps-android-api-2android-maps

Android Google map version-2 show direction and Google map icon


In my Android application my map screen shows direction and Google map when click marker on the map. I use the following in my application.

XML:

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.MapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

In code:

GoogleMap googleMap = ((MapFragment) getFragmentManager().findFragmentById(
        R.id.map)).getMap();

I have marked the direction and Google map icon marked in blue color. please see the image of my map screen.

enter image description here

How to hide direction and Google map icon from map fragment?


Solution

  • TL;DR version:

    Try overriding OnMarkerClickListener and return true.


    Longer version:

    When you return true you say to GoogleMap

    I, the developer, handled a click on the Marker. You, the GoogleMap, don't have to do anything.

    So as a result GoogleMap does not perform its default action which in this case would be: show those buttons (which you don't want).