3

I've got a problem with the google map object in the new v2 API. I'm trying to add methods to show and hide the map object, but I can't seem to get it to work.

For example - I have a class called MyMapFragment which extends the MapFragment class.

I've tried a couple of ways which I've seen posted here, but neither seem to work for me.

Option 1: Inside the MyMapFragment class, I've tried calling:

this.getFragmentManager().beginTransaction().hide(this).commit();

Option 2: I've tried to hide the actual containing view, using something like the following:

getActivity().getWindow().findViewById(CONTENT_VIEW_ID);
v.setVisibility( View.INVISIBLE );

Both of these options hide the UI controls (i.e. the zoom controls) of the map successfully, but the actual map does not get hidden.

Does anyone see what may be wrong with this method of hiding the map fragment?

Help muchly appreciated!

koriner
  • 113
  • 2
  • 7

2 Answers2

2

Try to put it in the FrameLayout and then assign id to the layout and show/hide the whole layout with the method .setVisibility(View.GONE/View.VISIBLE)

Not sure if it's the correct way but it works for me.

Hope it helps!

Imane Fateh
  • 2,418
  • 3
  • 19
  • 23
Pilsner25
  • 21
  • 2
1

I had the same problem (see MapFragment and Camera seem to interfere with each other in the same Activity). In my case, user CommonsWare suggested that my problem was because I was using two SurfaceView objects in a single Activity, which I was. When I used two activites for the one app then my problem went away. Perhaps that's the source of the problem here?

Community
  • 1
  • 1
gisking
  • 290
  • 2
  • 3
  • 8
  • Ah yes, I think this is exactly the problem. The main activity does use a SurfaceView, and I'm adding a new FrameLayout containing the map fragment to that activity. Is it possible to use another activity to hold the map fragment/view but display it in or on top of the base activity? (I'm very new to Android so forgive me if these are basic questions!) – koriner Mar 13 '13 at 22:36