What is the equivalent of the cluster manager feature used in Google map on Huawei Map?

850 Views Asked by At

I am trying to implement Huawei Map Kit to my android project. As you know google provides cluster manager to group many items on a map based on zoom level. How can I implement same feature in Huawei Map?

3

There are 3 best solutions below

0
On BEST ANSWER

Take a look at the example. Is that what you are looking for?

 @Override
 public void onMapReady(HuaweiMap map) {
     mMap = map;

     // Set zoom
     mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.864716, 2.349014), 10));

     // Add markers clusterable
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.861716, 2.349014)).title("Marker1").clusterable(true));
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.862716, 2.349014)).title("Marker2").clusterable(true));
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.863716, 2.349014)).title("Marker3").clusterable(true));
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.864716, 2.349014)).title("Marker4").clusterable(true));
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.865716, 2.349014)).title("Marker5").clusterable(true));
     mMap.addMarker(new MarkerOptions().position(new LatLng(48.866716, 2.349014)).title("Marker6").clusterable(true));

     // Set markers clusterable
     mMap.setMarkersClustering(true);
 }
2
On

This is the documentation about Huawei Map Kit Clustering Markers. You can also refer to sample code provided by @deadfish.

I’d like to add a useful tool, which is based on Google's open-source tool and adapts to the Huawei Map cluster manager. You are advised to integrate the tool to cluster markers.

Usage:

  1. Open Gradle, click library->Tasks->build->assemble.
  2. After Run, find 3rd-maps-utils-2.1.0-yyyyMMdd.aar file from Github in library/build/outputs/aar/ path.
  3. Copy 3rd-maps-utils-2.1.0-yyyyMMdd.aar file to your own app/libs/ path.
  4. Add codes below in project build.gradle file.
allprojects {
       repositories {
              ...
              flatDir {
                     dirs 'libs'
              }
       }
}
  1. Add codes below in app build.gradle file.
dependencies {
    implementation(name: '3rd-maps-utils-2.1.0-yyyyMMdd', ext: 'aar')
    ...
}

UPDATE

enter image description here

0
On

You could check out my ClusterManager with example on Huawei Map.

https://github.com/hunterxxx/huawei-map-clustering