In a previous stackexchange question

I got help to use a geojson property to create layers on a map.

However, the layer control only keeps the latest point he gets so I can't switch on/off all points of a "destination".

If all markers have a different destination it will work but if some markers shares same destination it fails.

Here is the playground.

The geojson used is just an extract for the test. I 'need' to place hundreds of points in a few categories ("destination" in my case). Let's say, all museum and all schools, and I'd like to control the visibility of the layer on the map.

  • 1
    See stackoverflow.com/questions/33478202/…
    – ghybs
    Nov 18, 2016 at 10:06
  • @ghybs It's almost working, I notice that all the checkboxes are unchecked by default. So that once I click the control to uncollapse it, all the layers disappear. And I have to check them one by one to display them again. playground is updated
    – mmeinert
    Nov 18, 2016 at 14:45
  • 1
    That is probably because you add your GeoJSON layer to the map, instead of the Layer Groups that are actually referenced as overlays in your Layers Control.
    – ghybs
    Nov 18, 2016 at 15:31
  • Indeed but what if I want the layers to be shown by default ? playground updated
    – mmeinert
    Nov 20, 2016 at 16:40
  • 1
    Add your Layer Groups to map, not your GeoJSON group. The ones that are referenced as overlays in your Layers Control.
    – ghybs
    Nov 21, 2016 at 10:15

1 Answer 1


Here is the solution, comments from @ghybs where valuable

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.