title: using google map in a fragment: onMapReady is never called
body: <p>I use in another fragment google maps that works fine. So when I had to do it for another fragment, inside the same app, I copy/paste the code and adapted the inflator and the findviewbyid. But onMapReady() is never called so googlemap stays null.</p>
  
  <p>I've seen the <a href="https://stackoverflow.com/questions/36809284/mapview-onmapready-never-called-in-fragment-for-load-google-map-in-mapview">MapView.onMapReady never called in Fragment for load Google Map in MapView</a> case which looks similar to mine but I'd like to understand the "implements OnMapReadyCallback" mechanism.</p>
  
  <p>What is the mechanism to call onMapReady? I suppose when the call to mapView.getMapAsync(this) happens?</p>
  
  <pre><code>    import android.app.Fragment;
      import android.content.Context;
      import android.os.Bundle;
      import android.view.LayoutInflater;
      import android.view.View;
      import android.view.ViewGroup;
      import android.widget.Button;
      import android.widget.ScrollView;
      import android.widget.TextView;
      import android.widget.Toast;
  
      import com.google.android.gms.maps.CameraUpdateFactory;
      import com.google.android.gms.maps.GoogleMap;
      import com.google.android.gms.maps.MapView;
      import com.google.android.gms.maps.MapsInitializer;
      import com.google.android.gms.maps.OnMapReadyCallback;
      import com.google.android.gms.maps.model.BitmapDescriptorFactory;
      import com.google.android.gms.maps.model.CameraPosition;
      import com.google.android.gms.maps.model.LatLng;
      import com.google.android.gms.maps.model.MarkerOptions;
  
  
      public class LocalisationMonitoringFragment extends Fragment implements OnMapReadyCallback {
          private Context context;
          private static View view;
  
          private MapView mapView;
  
          static private GoogleMap googleMap;
  
          public LocalisationMonitoringFragment() {
              // Required empty public constructor
          }
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                   Bundle savedInstanceState) {
              super.onCreateView(inflater, container, savedInstanceState);
  
              view = inflater.inflate(R.layout.localization_monitor, null);
  
              mapView = (MapView) view.findViewById(R.id.loc_mapView);
              mapView.onCreate(savedInstanceState);
              mapView.onResume();
              mapView.getMapAsync(this);
              try {
           MapsInitializer.initialize(getActivity().getApplicationContext());
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
              return (view);
  
          }
  
     @Override
      public void onMapReady(GoogleMap map) {
          googleMap = map;
          LatLng sydney = new LatLng(latitude, longitude);
          googleMap.addMarker(new MarkerOptions().position(sydney).title("Marker Title").snippet("Marker Description"));
          CameraPosition cameraPosition = new CameraPosition.Builder().target(sydney).zoom(12).build();
          googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
      }
  </code></pre>
  
  <p>in the layout file I have:</p>
  
  <pre><code>&lt;com.google.android.gms.maps.MapView
          android:id="@+id/loc_mapView"
          android:layout_below="@id/loc_name_txt"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:layout_margin="20dp" /&gt;
  </code></pre>