TabActivity 中的多个地图 v2 [英] Multiple maps v2 in TabActivity

查看:37
本文介绍了TabActivity 中的多个地图 v2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用 MapView 对象在 TabActivity 的不同选项卡中拥有 2 个地图 v2.问题出现在以下场景中:

I'm currently trying to have 2 maps v2 in different tabs of a TabActivity using MapView objects. The problem arises in the following scenario:

  • 显示带有地图的tab1
  • 转到 tab2 以显示另一张地图
  • 在第二个选项卡中,第一个选项卡中的地图图像似乎与新地图重叠.见下图:

在右侧,您可以看到第一张地图仍然显示在其顶部.触摸事件将转到新地图,但这并没有真正的帮助.我花了很多时间尝试将我们的应用程序转换为使用片段并遇到其他类型的问题.其中之一是 http://code.google.com/p/android/issues/detail?id=40035 所以这也不是一个好的选择.

On the right you can see how the first map is still displayed on top of it. The touch events are going to the new map but that doesn't really help. I spent a lot of time trying to convert our app to use fragments and run into other types of issues. One of them being http://code.google.com/p/android/issues/detail?id=40035 so that's not a good option either.

到目前为止,我还没有找到任何解决方法.为了轻松尝试各种更改,我编写了一个简单的应用程序并在此处提供:https://github.com/cristizmf/TestMapsV2.它只需要地图库项目的正确位置和清单中的一个好的地图键.

So far I haven't been able to find any workaround. To easily try various changes I wrote a simple application and made it available here: https://github.com/cristizmf/TestMapsV2. It needs only the right location for maps library project and a good maps key in manifest.

任何想法将不胜感激.

稍后我为此记录了一个问题:https://code.google.com/p/gmaps-api-issues/issues/detail?id=5027&thanks=5027&ts=1362071369

Later edit: I've logged an issue for this: https://code.google.com/p/gmaps-api-issues/issues/detail?id=5027&thanks=5027&ts=1362071369

推荐答案

几天前我遇到了同样的问题,正在纠结该怎么办.

I ran into the same issue a few days ago and was pulling my hair out over what to do.

最初我将我的应用程序设置为Tabs the Fragment way"此处 避免使用已弃用的 TabActivity,并使用了此技巧 允许我将 Maps v1 与 Fragments 合并.它基本上只是将 Activity 屏蔽为 Fragment.

Originally I had my app set up with "Tabs the Fragment way" as seen here to avoid the deprecated TabActivity, and used this hack to allow me to incorporate Maps v1 in with the Fragments. It basically just masks an Activity as a Fragment.

但是为了简单起见,后来切换到 TabActivity 更进一步/它更适合整个应用程序.但现在显然这个 2x Maps v2 片段问题已经成为一个问题..

But then switched to TabActivity further down the track for simplicity / it was better suited for the whole app. But now obviously this 2x Maps v2 fragment problem has become an issue..

所以我已经恢复到带片段的标签",并且只为每个标签设置了如上所述的黑客设置",这允许每个标签都有一个活动,并且每个标签显示一个以上的地图 v2.我没有深入研究它,但它似乎在做 atm 的工作,只是将一些代码放在一起进行测试..

So I have reverted back to "Tabs with Fragments" and just have the "hack setup" as mentioned above for each tab, which allows to have an Activity for each tab, AND having more than one Maps v2 displaying for each Tab. I haven't gone into too much depth with it, but it seems to be doing the job atm, with having just thrown some code together to test it out..

不知道您是否仍然对此有疑问/这显然不是最正确的解决方案,但只是想我会分享我的两分钱,以防您仍然需要它.

Don't know if you're still having an issue with this / this obviously isn't the most correct solution, but just thought I'd share my two cents incase you still needed it.

干杯.

这篇关于TabActivity 中的多个地图 v2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆