Фрагмент карты V2 во фрагменте
У меня проблемаИсключение нулевого указателя в getmap () " в Google Фрагменты карты. Я хочу вставить mapfragment во фрагмент. Пожалуйста, просмотрите код и сообщите, правильно ли я принимаю appraoch или нет .. и дайте мне знать, что именно мне нужно сделать с моим кодом, чтобы он работал
Файл моего макета:
public class PerxDetailedFragment extends SupportMapFragment {
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
static final LatLng KIEL = new LatLng(53.551, 9.993);
GoogleMap map;
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
FragmentTransaction ft = getFragmentManager().beginTransaction();
map = ((SupportMapFragment) getFragmentManager().findFragmentById(R.id.map))
.getMap();
SupportMapFragment fmap = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);
if (fmap == null) {
fmap = SupportMapFragment.newInstance();
ft.add(R.id.map, fmap);
}
ft.commit();
Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)
.title("Hamburg"));
Marker kiel = map.addMarker(new MarkerOptions()
.position(KIEL)
.title("Kiel")
.snippet("Kiel is cool")
.icon(BitmapDescriptorFactory
.fromResource(R.drawable.ic_launcher)));
// Move the camera instantly to hamburg with a zoom of 15.
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
// Zoom in, animating the camera.
map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
return inflater.inflate(R.layout.perx_detailed, null, false);
}
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
}
}