为什么我从谷歌地图V2得到这个错误?

时间:2015-04-07 07:56:13

标签: android google-maps google-maps-android-api-2

我编写简单的应用程序以在谷歌地图中显示地图,我的代码为:

public class MainActivity extends FragmentActivity {
    private static final LatLng LATLNG_IRAN = new LatLng(32.379961, 54.005356);
    private GoogleMap googleMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
        googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LATLNG_IRAN, 4));


    }



}


但是当我运行应用程序时,我收到此错误:

Caused by: java.lang.NullPointerException: CameraUpdateFactory is not initialized
            at com.google.android.gms.internal.jx.b(Unknown Source)
            at com.google.android.gms.maps.CameraUpdateFactory.nB(Unknown Source)
            at com.google.android.gms.maps.CameraUpdateFactory.newLatLngZoom(Unknown Source)
            at com.example.behzad.googlemap.MainActivity.onCreate(MainActivity.java:26)

在这一行:

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(LATLNG_IRAN, 4));


我该如何解决?

0 个答案:

没有答案