7

I want to migrate Google Maps functionality to HMS. Most of the parts were easily migrated to Huawei, but I have functionality of Clustering and I'm using ClusterItem and ClusterManager with DefaultClusterRenderer for my GoogleMap to show clusters of markers as one marker if there is alot of them on map.

This functionality is lacking in HMS. I found Marker and HWMarkerCluster but its completely different system and HWMarkerCluster is not even found in option of imported classes for Android. It was found only for Javascript API.

Any suggestions if there is any alternative in HMS? Because I'm reading Map Kit documentation for hour and I cant find anything.

martin1337
  • 2,384
  • 6
  • 38
  • 85

2 Answers2

3

Here is the documentation for marker cluster. https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/hms-map-drawonthemap#h2-1586915875534

It works perfectly fine for a small amount of markers. Simply add .clusterable(true)

Alternatively, you could use the library I have created for clustering where it can render 10,000 markers without any lag.

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

Hunter
  • 3,080
  • 20
  • 23
  • This is great, I havent seen this section in documentation before. They had to add it after I wrote this issue. But it is not working properly. I have like 150 markers in 30km range on map and it lagged my map immediatelly as I get there. I suppose it is not working as expected yet. – martin1337 Jun 11 '20 at 06:10
  • I waited 2 minutes until my app unfroze and then it worked. Might be some performance issue in Huawei library – martin1337 Jun 11 '20 at 06:26
  • @martin1337 feel free to try out my library: https://github.com/hunterxxx/huawei-map-clustering. It will perform well even with large number of markers. – Hunter Jul 08 '20 at 05:25
2

For functionality of Clustering, you can refer to @Hunter’s documentation. I also want 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')
    ...
}
zhangxaochen
  • 32,744
  • 15
  • 77
  • 108