Reputation: 1660
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.getController().setZoom(14);
mapView.getController().setCenter(new GeoPoint(46814000,17977000));
return mapView;
}
Hope somebody knows how to solve this.
Thanks
Upvotes: 2
Views: 3175
Reputation: 196
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
Upvotes: 1