0

I am using a single activity with multiple frgmetns where each holds a MapView in its fragment.

This is a reported bug, that i occurs on 4.0.4 android (probably on 4.0 also) but works properly on higher versions.

https://code.google.com/p/gmaps-api-issues/issues/detail?id=5027

Multiple maps v2 in TabActivity

When a new fragment is added both maps show. If a third fragment is added all tree maps are shown. I have tried applying the hideStupidMaps fix as discussed above but it provides no result( i have added calls to hide/show maps in onResume/onPause).

I have also added calls to hide the previous map before calling FragmentManager and its transaction but no result.

I have tried setting MapView visibility to INVISIBLE but also no result, the map previos map still shows, like no refresh is happening?

Is there a way to set zIndex to MapView? I know you can set z index when using MapFragment through GoogleOptions but i cant find an option to do that with MapView?

   GoogleMapOptions options = new GoogleMapOptions();
   options.zOrderOnTop(true);
   fragmentMap = SupportMapFragment.newInstance(options);
Community
  • 1
  • 1
JanBo
  • 2,925
  • 3
  • 23
  • 32

1 Answers1

0

I have managed to get it working. The problem was that i was actually calling hideStupidMaps after fragment transaction, and on 4.0.4 android it didnt have any effect while it worked on 4.1. I moved the call before the Fragment transaction and it worked. The only downfall is that for a moment the user can see the map disappear before Fragment animation starts.

I have also added a OnBackStackChangedListener where i would show the previously hidden map when returning via back button/action bar.

Hope it helps someone, and a piece of advise, avoid multiple maps in fragments if you can...

JanBo
  • 2,925
  • 3
  • 23
  • 32