1

I'm trying to implement the Leaflet.MarkerCluster.LayerSupport plugin following this example, however while it seems easy to add and remove data using buttons, there is nothing here to indicate one can use the same format with an external checkbox input.

I've been trying to take apart the L.controls inside the map for using externally but it seems that's rather difficult as its built around leaflet.js code. Does anyone have any suggestions for how the same functions for Leaflet.MarkerCluster.LayerSupport called upon by a button with "data-group="2" data-op="checkOut" (for example) could be applied to an external checkbox?

1 Answer 1

2

There should be no special difficulty in implementing what you describe.

The code for the button actions in the plugin example page is available on the repository:

https://github.com/ghybs/Leaflet.MarkerCluster.LayerSupport/blob/master/examples/mcgLayerSupport-controlLayers-realworld.388.html#L139-L153

Using checkboxes instead of buttons should be quite simple, but instead of just performing a simple action, you would first test the checked property of your checkbox, to determine whether the user wants to add or remove the Layer Group from the map.

You should have plenty resources for this specific usage, on GIS SE, SO and on the Web.

For e.g. https://stackoverflow.com/questions/39135100/leaflet-how-to-show-all-layers-on-a-map/39136839#39136839

1
  • Whoops, was looking in the plugin rather than the page! Thank you much! Commented Nov 28, 2016 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.