osmdroid - mapview in fragment
I'm using the Android Compatibility Package and I've tried to add the MapView
in the Fragment
's onCreateView
. However the map doesn't zoom or show the right coordinates. It only shows the whole world map (lowest detail).
Here is the simple code that should normally work
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
MapView mapView = new MapView(getActivity(), 256);
mapView.开发者_C百科getController().setZoom(14);
mapView.getController().setCenter(new GeoPoint(46814000,17977000));
return mapView;
}
Hope somebody knows how to solve this.
Thanks
to @Tony you probably have figured this out already but the MapFragment only exists in the compatibility packages. The common solution at this time is to use MapActivity as the activity and add fragments there or to use the compatibility package and add the Fragment in by way of a TabHost and a LocalActivityManager http://stackoverflow.com/questions/5109336/mapview-in-a-fragment-honeycomb
精彩评论