Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 994
Jan Vorisek Avatar asked Aug 13 '13 01:08

Jan Vorisek


1 Answers

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

  • onCreate(Bundle)
  • onResume()
  • onPause()
  • onDestroy()
  • onSaveInstanceState()
  • onLowMemory()

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 imaginary is not visible.

like image 132
Ingweland Avatar answered Sep 26 '22 19:09

Ingweland