Google Map Android API v2 getMap() error

主宰稳场 提交于 2019-12-13 09:07:42

问题


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 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;
    }
}

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


回答1:


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.



来源:https://stackoverflow.com/questions/14537196/google-map-android-api-v2-getmap-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!