Matthes Schucht
Matthes Schucht

Reputation: 93

Show Cluster Bounds always

I'm looking for a way to make the Bounds of a clusters permanently visible, not only on mouseover. So far I didn't find a solution. I'm using the markercluster plugin for leaflet. I have to insert Datapoints with an Information about the local Bandwidth. I want those to get clustered and then the Area to get outlined by a specific colour. Thanks for your support guys :-)

Greetings Matthes

Upvotes: 3

Views: 1221

Answers (2)

Matthes Schucht
Matthes Schucht

Reputation: 93

Ok, I found the solution:

I add the Coverage as a Polygone with the getConvexHull Function. These Polygones I add into a layergroup. This Layergroup ist then allways applied to the map, when an animnation ist done. Before the loop generates the ConvexHull of each cluster, all Layers of the Layergroup get deleted, so there are no bound rendered on the map.

This is the Code [https://jsfiddle.net/mad__97/3v7hd2vx/211/][1]

Thanks for your support

Upvotes: 6

ghybs
ghybs

Reputation: 53225

Welcome to SO!

You should simply use the private method _showCoverage() of Leaflet.markercluster plugin, and provide it with an object with at least layer member being the cluster object which you want to show coverage of.

mcg._showCoverage({ layer: cluster }); // cluster is NOT your cluster group!

But you need to be outside of your cluster group animation, and the cluster must have more than 2 children.

Example: https://jsfiddle.net/3v7hd2vx/208/

Upvotes: 1

Related Questions