Search code examples
androidandroid-maps-extensions

android-map-extensions weird clustering behavior


I'm currently using android-map-extensions to cluster markers on google map. However, sometimes two markers are clustered when they are really far, sometimes they have to be almost overlapping each other to be clustered together. I've been trying to wrap my head around this for a couple of days and haven't figured it out. Below is the examples (btw, sorry for the bad english and I don't have enough reputation to post images so imgur to the rescue):

  1. should already clustered : https://i.sstatic.net/OtaRd.jpg
  2. should not clustered until zoom out far enough (1-2 more zoom level) : https://i.sstatic.net/ih9Ew.jpg

How can I fix this, changing the clusterSize as document does not really help


Solution

  • Android Maps Extensions uses grid based clustering and what you describe is part of how it works.
    You have a couple of options:

    1. writing your own clustering strategy for it (e.g. distance based)
    2. finding a proper clusterSize for your case; this might work if all your markers have fixed and static positions; keep in mind choosing between 128 and 128.1 can make a big difference
    3. trying out a different library, e.g. Clusterkraf or Android Maps Utils, which use distance based clusering

    Disclosure: I'm a developer of Android Maps Extensions