3

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?

Alize Dronna
  • 197
  • 7
  • You can cluster markers but afaik currently Huawei Maps SDK does not support ClusterManager API yet. – m0skit0 Jun 09 '20 at 10:36

3 Answers3

3

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);
 }
deadfish
  • 11,996
  • 12
  • 87
  • 136
2

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

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

Hunter
  • 3,080
  • 20
  • 23
1

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

zhangxaochen
  • 32,744
  • 15
  • 77
  • 108
  • Hi. I am currently trying to implement it but do not know-how. I could not find "library" in a Gradle window to run assemble and extract that dependency. Also how we really use it? Is there Google's ClusterManager which we can use with HuaweiMap or what? Please, it is really important for me if you can explain I'd really be thankful. – Aytaj Jan 22 '21 at 08:08
  • I have update the screenshoot where you can find the assemble in the upper right corner of AS by clicking "Gradle" :) – zhangxaochen Jan 22 '21 at 09:25