Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
165 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...