L.Control.Layers - set default to off?

6,571 views
Skip to first unread message

bgar...@gmail.com

unread,
Feb 25, 2013, 10:46:32 AM2/25/13
to leafl...@googlegroups.com
I'm using the L.Control.Layers function and I was wondering if there was a way to set the overlay layers so they default to off or "unchecked" when the map first loads?

Bryan McBride

unread,
Feb 26, 2013, 1:12:12 AM2/26/13
to leafl...@googlegroups.com
Just add the layers to the Layers control without adding them to the map.
Message has been deleted
Message has been deleted

Nazareno Martin

unread,
Mar 1, 2016, 9:03:45 AM3/1/16
to Leaflet
Hi! i have the same problem. I need that all checkbox start as "checked" but its state are "unchecked". How i can resolve it? any idea? Thanks!

ghybs

unread,
Mar 8, 2016, 2:48:11 AM3/8/16
to Leaflet
Hi,

The Layers Control listens to what happens on the map.

So if you programmatically add your overlays to the map (`map.addLayer(myOverlay)`), the Layers Control will tick its checkboxes to reflect their presence.

NOTE: please use Stack Overflow or GIS Stack Exchange to get faster support on your projects.

Hope this helps.

Максим Кандауров

unread,
Mar 23, 2016, 7:33:45 AM3/23/16
to Leaflet
controlMaps.addOverlay(Layer,LayerName);
if (enable) Layer.addTo(map);


понедельник, 25 февраля 2013 г., 20:46:32 UTC+5 пользователь Brandon Garman написал:
Reply all
Reply to author
Forward
0 new messages