title: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(boolean)
body: <p>pls help. my app crashes when i open my application on my fragment. i am using a navigation drawer.</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to invoke virtual method 'void com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(boolean)' on a null object reference
                                                                      at johnbea.com.mysystem.LanlordMapFragment.onCreateView(LanlordMapFragment.java:68)
                                                                      at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
                                                                      at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
                                                                      at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
                                                                      at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
                                                                      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
                                                                      at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
                                                                      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
                                                                      at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
                                                                      at android.os.Handler.handleCallback(Handler.java:789)
                                                                      at android.os.Handler.dispatchMessage(Handler.java:98)
                                                                      at android.os.Looper.loop(Looper.java:164)
                                                                      at android.app.ActivityThread.main(ActivityThread.java:6541)
                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                      at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
  </code></pre>
  
  <p>here is the code on navigation drawer before going to the map fragment</p>
  
  <pre><code> private void displaySelectedScreen(int ID){
  
      Fragment fragment = null;
      switch (ID){
          case R.id.add_apartment:
              fragment = LandlordAddApartment.newInstance(id, username);
              FragmentManager addfragmentManager = getSupportFragmentManager();
              addfragmentManager.beginTransaction();
              break;
          case R.id.reserve_request:
              fragment = new LandlordReservation();
              break;
          case R.id.ver_request:
              fragment = LandlordVerification.newInstance(id, username);
              FragmentManager verificationfragment = getSupportFragmentManager();
              verificationfragment.beginTransaction();
              break;
          case R.id.landlord_log_out:
              fragment = LandlordLogout.newInstance(id, username);
              FragmentManager fragmentManager = getSupportFragmentManager();
              fragmentManager.beginTransaction();
              break;
          case R.id.map2:
              fragment = new LanlordMapFragment();
  
      }
      if(fragment != null){
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          ft.replace(R.id.content_landlord, fragment);
          ft.commit();
      }
      DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      drawer.closeDrawer(GravityCompat.START);
  
  }
  </code></pre>
  
  <p>here is my fragment where the google map.. im getting trouble with getting the current location on this fragment. it already took me 2 weeks already still i cant figure it out.. can someone please help me :(</p>
  
  <pre><code>   @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
      super.onViewCreated(view, savedInstanceState);
      getActivity().setTitle("MAP");
  
      if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &amp;&amp; ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
          // TODO: Consider calling
          //    ActivityCompat#requestPermissions
          // here to request the missing permissions, and then overriding
          //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
          //                                          int[] grantResults)
          // to handle the case where the user grants the permission. See the documentation
          // for ActivityCompat#requestPermissions for more details.
          return;
      }
      mGoogleMap.setMyLocationEnabled(true);
      LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
      Criteria criteria = new Criteria();
      String bestProvider = locationManager.getBestProvider(criteria, true);
      Location location = locationManager.getLastKnownLocation(bestProvider);
      if (location != null) {
          onLocationChanged(location);
      }
      locationManager.requestLocationUpdates(bestProvider, 20000, 0, (android.location.LocationListener) getActivity());
      SupportMapFragment mapFragment = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.map1);
  
      mapFragment.getMapAsync(this);
  }
  
  
  
  /*@Override
  public void onMapReady(GoogleMap googleMap) {
      MapsInitializer.initialize(getContext());
      mGoogleMap = googleMap;
  
  
      googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
  
      googleMap.addMarker(new MarkerOptions().position(new LatLng(13.137769, 123.743652)).title("Legazpi property").snippet("asdasdasd"));
      CameraPosition legazpi =   CameraPosition.builder().target(new LatLng(13.137769, 123.743652)).zoom(16).bearing(0).tilt(45).build();
      googleMap.moveCamera(CameraUpdateFactory.newCameraPosition(legazpi));
  
     // LatLng legazpi = new LatLng(-13.137769, 123.743652);
   //   mGoogleMap.addMarker(new MarkerOptions().position(legazpi).title("Legazpi property"));
    //  mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(legazpi));
  
  
          //return;
  
      }
  </code></pre>
  
  <p>*/</p>
  
  <pre><code>@Override
  public void onLocationChanged(Location location) {
  
      TextView locationTv = (TextView) view.findViewById(R.id.latlongLocation);
      double latitude = location.getLatitude();
      double longitude = location.getLongitude();
      LatLng latLng = new LatLng(latitude, longitude);
      mGoogleMap.addMarker(new MarkerOptions().position(latLng));
      mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
      mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(15));
      locationTv.setText("Latitude:" + latitude + ", Longitude:" + longitude);
  
  }
  
  public void onProviderDisabled(String provider) {
      // TODO Auto-generated method stub
  }
  
  public void onProviderEnabled(String provider) {
      // TODO Auto-generated method stub
  }
  
  public void onStatusChanged(String provider, int status, Bundle extras) {
      // TODO Auto-generated method stub
  }
  </code></pre>