【问题标题】:Google Map Android API v2 getMap() errorGoogle Map Android API v2 getMap() 错误
【发布时间】:2013-01-26 13:02:53
【问题描述】:

您好,我正在尝试使用 Google Map Android API v2 在我的应用中实现 Google 地图显示,我正在尝试遵循 here 中的解决方案。

代码似乎没问题,除非我尝试了这部分:

public class MapFragment extends SherlockMapFragment {
    private GoogleMap mMap;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle    savedInstanceState) {
    View root = super.onCreateView(inflater, container, savedInstanceState);
    mMap = getMap();
    return root;
    }
}

getMap() 给出错误,因为它表示方法 getMap() 未定义类型 MapFragment。这是什么意思?

【问题讨论】:

  • 放更多的getMap()代码;
  • getMap() 没有代码,因为我只是在关注解决方案,不确定 getMap() 方法来自哪里
  • 使用这个例子xrigau.wordpress.com/2012/03/22/…而不是你实现的。
  • 谢谢你会看看它,看看它是如何进行的,但我更愿意为我的问题找到一个解决方案,而不是尝试重新编写整个实现,因为你的例子似乎更令人困惑跨度>

标签: java android android-maps-v2 mapfragment


【解决方案1】:

getMap() 方法是com.google.android.gms.maps.SupportMapFragment 类的一部分。您的SherlockMapFragment 应该首先扩展它,因此仅使用getMap() 应该可以正常工作,但除非您使用 MapFragment 中的 ActionBar 而不是您的 FragmentActivity 进行一些实际的额外自定义,否则您可以扩展 SupportMapFragment in第一名。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    相关资源
    最近更新 更多