Mapview and fragment

A few months ago, I saw several topics that using MapView inside a fragment was a bit complicated / impossible. I would like to know if atm (June) is a workaround? My application (Android 3.0) essentially works with the Fragment system, and I need to display the map in one of these fragments.

+6
source share
3 answers

Currently, I know only one solution. I came across this when I ran into the same problem. https://github.com/petedoyle/android-support-v4-googlemaps .

EDIT

Here is the new fork version based on r9 https://github.com/rfc1459/android-support-v4-googlemaps

You can create it via eclipse or download the compiled version here https://github.com/rickbarrette/android-support-v4-googlemaps/downloads

+7
source

There is already another question . Basically a workaround is to create an Activity Manager and TabHost and create one tab containing MapActivity. This way you can load a separate MapActivity inside the fragment.

For more information, see the sample project provided by the original answering machine.

+3
source

Since this question was posted, Google most recently (early December '12) published the Android Maps API V2. Like other functions, it is designed to work with Fragment and eliminates the pointlessness of MapActivity .

https://developers.google.com/maps/documentation/android/

So, it seems that now we can happily use maps in Fragments without the need for hacking.

The only weak drawback that I have encountered so far after the initial game with this new API is that older devices seem to require the user to install Google Play Services first, which may cause some users to break a little. Like them.

0
source

Source: https://habr.com/ru/post/891423/


All Articles