Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HMS Map Kit - Clustering

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.

like image 801
martin1337 Avatar asked May 13 '20 07:05

martin1337


2 Answers

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

like image 155
Hunter Avatar answered Sep 28 '22 01:09

Hunter


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')
    ...
}
like image 22
shirley Avatar answered Sep 28 '22 01:09

shirley