Google Map returning nullpointerexception Google Maps Android V2

前端 未结 3 1733
谎友^
谎友^ 2020-12-06 22:36

I have a google map in a fragment in my application. Funny thing is that the map loads, but the logcat displays a NullPointerException

3条回答
  •  眼角桃花
    2020-12-06 23:13

    Just do like the below

    @Override
        public void onMapReady(GoogleMap googleMap) {
    
            MapsInitializer.initialize(getContext());
            map = googleMap;
            map.setMyLocationEnabled(true);
            // Updates the location and zoom of the MapView
            CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(new LatLng(43.1, -87.9), 10);
            map.animateCamera(cameraUpdate);
        }
    

提交回复
热议问题