This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Integrating OSM MapView in fragments

0

As per asked in here... I am trying to implement OSM MapView in fragments. I've seen people done this in onCreateView

return new MapView(getActivity(), 256);

However I am not sure how to change my implementation of an Activity into Fragments... right now my Activity codes are like this:

MapView myOpenMapView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
    setContentView(R.layout.offline_map_activity);
    myOpenMapView = (MapView) findViewById(R.id.openmapview);
    myOpenMapView.getTileProvider().clearTileCache();

    //.... code continues
}

But I'm not sure how to convert this part of the code when implemented in Fragments:

setContentView(R.layout.offline_map_activity);
myOpenMapView = (MapView) findViewById(R.id.openmapview);

How do I instantiate the MapView object properly and return it in the onCreateView method?

asked 20 Feb '13, 14:56

lyk's gravatar image

lyk
41446
accept rate: 0%

edited 21 Feb '13, 00:25

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

hmm, this site is not really about coding with some specific toolkit... However, please link your post here also in stackoverflow to mitigate the bad effects of crossposting.

(21 Feb '13, 00:31) aseerel4c26 ♦

I already hyperlinked the stackoverflow question under the word "here". Oh, is this forum not about openstreetmap/OSMDroid? If that's the case where can I ask about implementing fragments with OSMDroid?

(21 Feb '13, 03:31) lyk

@lyk: I saw the "here". I mean that it would be good to insert a link into your question at stackoverflow.

A forum or a mailing list (e.g. dev?) are probably better suited - but you may get an answer here, too. Wait a day or two.

(21 Feb '13, 08:27) aseerel4c26 ♦

Source code available on GitHub .