【发布时间】:2011-06-27 07:02:32
【问题描述】:
几个月前我看到了一些主题,关于在 Fragment 中使用 (Google)MapView 有点棘手/不可能的事实。我想知道atm(六月)是否有解决方法?我的应用程序(Android 3.0)本质上是在使用 Fragment 系统,我需要在其中一个 Fragment 中显示地图。
【问题讨论】:
标签: android android-layout android-fragments android-mapview
几个月前我看到了一些主题,关于在 Fragment 中使用 (Google)MapView 有点棘手/不可能的事实。我想知道atm(六月)是否有解决方法?我的应用程序(Android 3.0)本质上是在使用 Fragment 系统,我需要在其中一个 Fragment 中显示地图。
【问题讨论】:
标签: android android-layout android-fragments android-mapview
目前我只知道一种解决方案。当我遇到同样的问题时,我偶然发现了这一点。 https://github.com/petedoyle/android-support-v4-googlemaps.
编辑
这是一个基于 r9 https://github.com/rfc1459/android-support-v4-googlemaps 的新分支
您可以通过 eclipse 构建它或在此处下载已编译的版本https://github.com/rickbarrette/android-support-v4-googlemaps/downloads
【讨论】:
已经有另一个question。基本上解决方法是创建一个Activity manager 和一个TabHost 并创建一个包含MapActivity 的单个选项卡。通过这种方式,您可以在 Fragment 中加载单独的 MapActivity。
更多information见原回答者提供的示例项目。
【讨论】:
自发布此问题以来,Google 现已在最近(2012 年 12 月开始)发布了 V2 Android Maps API。除了其他功能外,它还设计为与Fragments 一起使用,并消除了MapActivity 的废话。
https://developers.google.com/maps/documentation/android/
所以看起来我们现在可以愉快地在 Fragments 中使用地图而无需 hack。
在最初使用这个新 API 后,到目前为止我遇到的唯一一个小缺点是,旧设备似乎要求用户首先安装 Google Play 服务,这可能会让一些用户产生一些抱怨。就像他们一样。
【讨论】: