I searched the docs of the new Google Android Map API v2, but didn't find anything about it. Before v2 we (officially) couldn't properly display more than one map per application (process). I assume that with MapFragment
implementation it's no longer an issue. I also know, that Fragments
can be self-contained since API 17. And, last but not least, there is compatibility package, which makes it possible to port it all back to at least API 8 (in API 7, there's no OpenGL 2.0 so the maps wouldn't work afaik).
Sa I have all the ingredients to port my app to Maps API v2 and implement the following scenario: ViewPager
contains Fragments
and each of them contains a MapFragment
.
But should I do it? I mean, would I face performance issues if I had e.g. 20 Fragments
containing MapFragments
in a ViewPager
?
If you found anything that addresses my concern in the docs or somewhere else, please tell me.
EDIT: Example usage: Let's imagine a screen containing informations about some specific item - place, event, article. Also let's imagine that, among other informations, it must contain a map to be fully functional. But I would like the user to be able to swipe to another item if he wants. Each item has its own map.
Side note: I know that I can implement one map outside the ViewPager
and just update it based on the currently displayed item, but it's not what I'm looking for - it's not user-centered design.
Possible solution (but not checked yet). ViewPager
only keeps a few (default - 3) Fragments in it's cache and recreates them when they're about to show up, so there won't be much memory overhead as only a few MapFragments
are needed. The performance problem may be the MapFragment
inflation which is quite heavy, I believe - but that can be solved with recycling of MapFragments
.
So why won't I implement it if I believe it will work nice? There's another problem which makes it impossible to move MapFragments
without the app look like it's broken. See this.