本文介绍了谷歌地图API的Andr​​oid V2的GetMap()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我想要实现谷歌地图使用谷歌地图API的Andr​​oid V2我的应用程序显示,而我试图按照here.

Hi I'm trying to implement Google Maps display in my app using Google Map Android API v2, and I am trying to follow the solution in here.

codeS似乎只是当我尝试这部分没关系:

Codes seem to be okay except when I tried this part:

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。这是什么意思?

The getMap() gives an error, as it says method getMap() is undefined for the type MapFragment. What does this mean?

推荐答案

的GetMap()方法的一部分 com.google.android .gms.maps.SupportMapFragment 类。你的 SherlockMapFragment 应摆在首位所以只用的GetMap() shoudl正常工作,但除非你是来扩展这个做一些实际的额外定制的动作条在MapFragment而不是你FragmentActivity,你可以延长 SupportMapFragment 摆在首位。

The getMap() method is part of the com.google.android.gms.maps.SupportMapFragment class. Your SherlockMapFragment should be extending this in the first place so just using getMap() shoudl work properly but unless you're doing some actual extra customizations with the ActionBar in the MapFragment and not your FragmentActivity, you can just extend SupportMapFragment in the first place.

这篇关于谷歌地图API的Andr​​oid V2的GetMap()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-19 22:15