androidgoogle-mapsfragment

MapView displays blank, but MapFragments work normally


Hello I'm using Fragment based layout in my application - everything goes fine - I am using one special MapFragment and some other PageFragments to display data. MapFragment works fine - map is display with no problems and I am able to draw on it etc.

Now I wanted to add small map view into one of my PageFragments.

I tried like:

<com.google.android.gms.maps.MapView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        android:id="@+id/mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#00000000"
        android:clickable="true"
        map:uiCompass="true"
        map:uiZoomControls="true"
        map:zOrderOnTop="true" >
    </com.google.android.gms.maps.MapView>

No XML errors, etc. App is working normally - my PageFragment is correctly displayed, but the map view remains blank. Any ideas?


Solution

  • You must forward lifecycle methods from your Activity or Fragment to get MapView working. In particular:

    http://developer.android.com/reference/com/google/android/gms/maps/MapView.html

    Just in case someone missed, this is valid for Google Maps API v2. If you do not override these methods you may still see the map grid, map controls etc, but the map imagery is not visible.