Multiple Map fragment in action bar tab

2019-08-19 07:16发布

问题:

Basically what i am trying to do is Tab1 -> Organisation Map Fragment Tab2 -> City Map

How should I go about doing this. I tried following some tutorials but it gives me the error "You are allowed to have single MapView in a MapViewActivity". Can some one please help me out

回答1:

It's not possible to do this. As the message says, only one map per Activity.



回答2:

As Joe and the error message says, you can only have one mapview in a single activity.

What you could do (if you still want to use tabs) is just not change the fragment when the tab changes, and instead reload the map with different data.



回答3:

Google released the Map API Version 2. This finally allows to use a MapFragment and a SupportMapFragment. This allows adding Maps to ViewPagers and to Activities that do not extend MapActivity. It should also allow you to have multiple maps in one Activity