マップから自分の位置を取得できません。ヌルポインタ例外がスローされます。マップからmylocationを取得しようとするとnullポインタ例外が発生しています
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
try {
mMap = ((SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.mapFrag)).getMap();
} catch (Exception e) {
e.printStackTrace();
}
}
// Check if we were successful in obtaining the map.
if (mMap != null) {
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(true);
mMap.getUiSettings().setZoomControlsEnabled(true);
putMarkerOnMap(mMap.getMyLocation().getLatitude(),mMap.getMyLocation().getLongitude());
}
それは私がここでputMarkerOnMap(LAT、LNG) 関数を呼び出す行...でエラーがスローされます、その関数
public void putMarkerOnMap(double la , double lo){
LatLng position = new LatLng(la,lo);
mMap.addMarker(new MarkerOptions().position(new LatLng(la, lo)).title("Your Location"));
CameraPosition campos = new CameraPosition.Builder().target(position).zoom(15)
.bearing(90)
.tilt(40)
.build();
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(campos));
}
実際に私は私のフラグメントでFusedLocationのAPIを使用することができます –
はい確認することができます....フラグメント内の場所を必要とします。 –
最初に試してみましょう..!あなたの協力のおかげで –