Clustering map markers on zoom out and unclustering on zoom in

前端 未结 4 1367
南旧
南旧 2020-12-30 17:19

I am using the Google Map Android clustering Utitlity With Google Maps v2 play services.

I am not getting the behavior I expected. As you can see in the two images

4条回答
  •  清歌不尽
    2020-12-30 17:54

    I realize this is an old question, but for those still using Pavel's excellent answer, also make sure that you change these two lines of code

    BitmapDescriptor descriptor = mIcons.get(cluster.getSize());
    ...
    mIcons.put(bucket, descriptor);
    

    replacing bucket like so:

    BitmapDescriptor descriptor = mIcons.get(cluster.getSize());
    ...
    mIcons.put(cluster.getSize(), descriptor);
    

    Otherwise clusters will be rounding to the nearest bucket size when merging/separating resulting in inaccurate bucket sizes.

    Kind of an obvious fix, but very easy to miss if you aren't paying attention to the exact values of your data.

    For anyone struggling:

    The simplest way to implement Pavel's answer while retaining Google's rendering algorithm is to download the default renderer (as linked in Correct Answer), modify the code, and set it as a custom renderer for your ClusterManager. The library is not friendly to external modification / overwriting, and it's a colossal pain in the butt to only overwrite this segment, because it uses so many other private methods and variables.

提交回复
热议问题