Cluster markers in Google Maps Android v2

2020-02-16 09:35发布

I have to place different markers on a GoogleMap from the Google Maps Android v2 API. The problem is that multiple markers are set to the same position (lat/lng), so the user only sees the "newest" marker.

Is there a possibility (in the best case: a library) that clusters different markers from the same area (in relation to the zoomlevel)?

I've already read about the MarkerClusterer, but this is designed for the JavaScript API.

8条回答
何必那么认真
2楼-- · 2020-02-16 10:36

if you are getting only the newest marker then you need to cluster all the markers

> private ClusterManager<MyItem> mClusterManager;

after addding your items

mClusterManager.addItem("your item");
mClusterManager.cluster();
查看更多
你好瞎i
3楼-- · 2020-02-16 10:36

For those of you who are having troubles with the performance of the Google Maps Android API Utility Library, we've created our own fast clustering library: https://github.com/sharewire/google-maps-clustering. It can easily handle 20000 markers on the map.

查看更多
登录 后发表回答