Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android v2 - Can't hide map fragment

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!

like image 876
koriner Avatar asked May 09 '26 11:05

koriner


1 Answers

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!

like image 64
Pilsner25 Avatar answered May 11 '26 01:05

Pilsner25