I need your help... I work on it until 3 days. My app is working with fragments. One of these fragments has to display a map from the Google Maps V2 api for Android.
SupportMapFragment mSupportMapFragment;
private GoogleMap googleMap;
int ZOOM_LEVEL=15;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View mTrackView = inflater
.inflate(R.layout.mylayout, container, false);
mSupportMapFragment = SupportMapFragment.newInstance();
FragmentTransaction fragmentTransaction = getChildFragmentManager().beginTransaction();
fragmentTransaction.add(R.id.mapwhere, mSupportMapFragment);
fragmentTransaction.commit();
return mTrackView;
}
@Override
public void onStart() {
// TODO Auto-generated method stub
super.onStart();
if(mSupportMapFragment!=null){
googleMap = mSupportMapFragment.getMap();
if(googleMap!=null){
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.getUiSettings().setMyLocationButtonEnabled(false);
googleMap.setMyLocationEnabled(false);
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(
new LatLng(12.12122,
17.22323), ZOOM_LEVEL);
googleMap.animateCamera(cameraUpdate);
}
}
}