1

I´m using google-maps-utils (only marker clustering) and the code is read-only.

dependencies {
    compile 'com.google.maps.android:android-maps-utils:0.5+'
}

I want to comment 3 lines in ClusterManager.java

    /**
     * Might re-cluster.
     */
    @Override
    public void onCameraIdle() {
        if (mRenderer instanceof GoogleMap.OnCameraIdleListener) {
            ((GoogleMap.OnCameraIdleListener) mRenderer).onCameraIdle();
        }

        // Don't re-compute clusters if the map has just been panned/tilted/rotated.
        CameraPosition position = mMap.getCameraPosition();
//        if (mPreviousCameraPosition != null && mPreviousCameraPosition.zoom == position.zoom) {
//            return;
//        }
        mPreviousCameraPosition = mMap.getCameraPosition();

        cluster();
    }
  1. Can i import this code to my app and edit these lines ?
  2. If yes, how can i do that ? (step by step)

I'm trying to import the modules but I'm doing something wrong.

Itapox
  • 579
  • 1
  • 7
  • 25
  • 2
    make a class which extends ClusterManager, @Override the method, copy-paste the original code and remove the unwanted lines. if this class is used inside the library by higher level classes things can get pretty difficult where I can't help you – Pali Dec 05 '17 at 01:14
  • thanks! it works. write answers to set correct answer. – Itapox Dec 05 '17 at 18:00

1 Answers1

1

If this is a high level class which you will use directly you can simply extend this class and override the method:

public class MyClusterManager<T extends ClusterItem> extends ClusterManager<T> {
  @Override
  public void onCameraIdle() {
    if (mRenderer instanceof GoogleMap.OnCameraIdleListener) {
      ((GoogleMap.OnCameraIdleListener) mRenderer).onCameraIdle();
    }
    CameraPosition position = mMap.getCameraPosition();
    mPreviousCameraPosition = mMap.getCameraPosition();
    cluster();
  }
}

and then:

ClusterManager<MyClusterItem> clusterManager = new MyClusterManager<MyClusterItem>();
// do something with your own clusterManager ...
Pali
  • 1,337
  • 1
  • 14
  • 40