11

I'm using leaflet to display a map. I have a control section that I'd like to be open by default, but I can't find a way to do it through the API.

Is there a way to do this?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Ethereal
  • 253
  • 1
  • 3
  • 7

2 Answers2

29

The collapsed option in the control will achieve this. You need that null for it to work though. An example:

var overlays = {
    "Title1": polyLayer1,
    "Title2": polyLayer1,
    "Title3": lineLayer,
    "Title4": pointLayer
            };

L.control.layers(overlays,null,{collapsed:false}).addTo(map);
chrki
  • 2,655
  • 16
  • 22
lendegroot
  • 416
  • 4
  • 5
0

The curly braces with the collapsed attribute did the trick!

PolyGeo
  • 65,136
  • 29
  • 109
  • 338