简体   繁体   English

操作栏选项卡中的多个地图片段

[英]Multiple Map fragment in action bar tab

Basically what i am trying to do is Tab1 -> Organisation Map Fragment Tab2 -> City Map 基本上我要做的是Tab1 - >组织地图片段Tab2 - >城市地图

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". 我尝试了一些教程,但它给了我错误“你可以在MapViewActivity中使用单个MapView”。 Can some one please help me out 有人可以帮助我

It's not possible to do this. 这样做是不可能的。 As the message says, only one map per Activity. 正如消息所说,每个Activity只有一个地图。

As Joe and the error message says, you can only have one mapview in a single activity. 正如Joe和错误消息所示,您在一个活动中只能有一个mapview。

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. 您可以做什么(如果您仍想使用制表符)只是在选项卡更改时不更改片段,而是使用不同的数据重新加载地图。

Google released the Map API Version 2 . 谷歌发布了Map API Version 2 This finally allows to use a MapFragment and a SupportMapFragment . 这最终允许使用MapFragment和SupportMapFragment This allows adding Maps to ViewPagers and to Activities that do not extend MapActivity. 这允许将地图添加到ViewPagers和不扩展MapActivity的活动。 It should also allow you to have multiple maps in one Activity 它还应该允许您在一个活动中拥有多个地图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM