@Override
  public void onMapReady(final GoogleMap googleMap) {
    this.googleMap = googleMap;
    googleMap.setMyLocationEnabled(true);
    if (callback != null) {
      callback.onMapReady(googleMap);
    }
    if (cameraChangeListener != null) {
      googleMap.setOnCameraChangeListener(cameraChangeListener);
    }
    googleMap.setOnMarkerDragListener(
        new GoogleMap.OnMarkerDragListener() {
          @Override
          public void onMarkerDragStart(Marker arg0) {}

          @SuppressWarnings("unchecked")
          @Override
          public void onMarkerDragEnd(Marker arg0) {
            googleMap.animateCamera(CameraUpdateFactory.newLatLng(arg0.getPosition()));
          }

          @Override
          public void onMarkerDrag(Marker arg0) {}
        });
  }
 @Override
 public void setViewPortChangeListener(final ViewPortChangeListener listener) {
   googleMap.setOnCameraChangeListener(
       new OnCameraChangeListener() {
         @Override
         public void onCameraChange(CameraPosition cameraPosition) {
           GoogleMapWrapper.this.onCameraChange(cameraPosition, listener);
         }
       });
 }
  public void addCluster(List<GridPoint> complaintDtos) {
    clearMap();
    GoogleMapCluster googleMapCluster;
    LatLngBounds.Builder builder = new LatLngBounds.Builder();
    ClusterManager<GoogleMapCluster> mClusterManager;
    mClusterManager = new ClusterManager<GoogleMapCluster>(getActivity(), googleMap);
    googleMap.setOnCameraChangeListener(mClusterManager);
    googleMap.setOnMarkerClickListener(mClusterManager);
    for (GridPoint complaintDto : complaintDtos) {
      googleMapCluster =
          new GoogleMapCluster(
              complaintDto.getLocation().getLatitude().doubleValue(),
              complaintDto.getLocation().getLongitude().doubleValue());
      mClusterManager.addItem(googleMapCluster);
      builder.include(googleMapCluster.getPosition());
    }

    if (complaintDtos.size() > 1) {
      LatLngBounds bounds = builder.build();
      CameraUpdate cu = CameraUpdateFactory.newLatLngBounds(bounds, 0);
      googleMap.animateCamera(cu);
    } else if (complaintDtos.size() > 0) {
      CameraPosition cameraPosition =
          new CameraPosition.Builder()
              .target(
                  new LatLng(
                      complaintDtos.get(0).getLocation().getLatitude().doubleValue(),
                      complaintDtos.get(0).getLocation().getLongitude().doubleValue()))
              .zoom(zoomLevel)
              .bearing(0)
              .tilt(45)
              .build();
      googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }
    markersDisplayed = false;
    heatmapDisplayed = false;
    clusterDisplayed = true;
  }
 public void removeCluster() {
   googleMap.clear();
   googleMap.setOnCameraChangeListener(null);
   googleMap.setOnMarkerClickListener(null);
 }
  @Override
  public MapView createViewInstance(ThemedReactContext context) {
    reactContext = context;
    mView = new MapView(context);
    mView.onCreate(null);
    mView.onResume();
    map = mView.getMap();

    if (map == null) {
      sendMapError("Map is null", "map_null");
    } else {
      map.getUiSettings().setMyLocationButtonEnabled(true);
      map.setMyLocationEnabled(true);

      // We need to be sure to disable location-tracking when app enters background, in-case some
      // other module
      // has acquired a wake-lock and is controlling location-updates, otherwise, location-manager
      // will be left
      // updating location constantly, killing the battery, even though some other location-mgmt
      // module may
      // desire to shut-down location-services.
      LifecycleEventListener listener =
          new LifecycleEventListener() {
            @Override
            public void onHostResume() {
              map.setMyLocationEnabled(true);
            }

            @Override
            public void onHostPause() {
              map.setMyLocationEnabled(false);
            }

            @Override
            public void onHostDestroy() {}
          };

      context.addLifecycleEventListener(listener);

      try {
        MapsInitializer.initialize(context.getApplicationContext());
        map.setOnCameraChangeListener(getCameraChangeListener());
        map.setOnMarkerClickListener(getMarkerClickListener());
        // add location button click listener
        map.setOnMyLocationButtonClickListener(
            new GoogleMap.OnMyLocationButtonClickListener() {
              @Override
              public boolean onMyLocationButtonClick() {
                CameraPosition position = map.getCameraPosition();
                mlastZoom = (int) position.zoom;
                return false;
              }
            });
      } catch (Exception e) {
        e.printStackTrace();
        sendMapError("Map initialize error", "map_init_error");
      }
    }

    return mView;
  }