TransWikia.com

Making leaflet control open by default

Geographic Information Systems Asked by Ethereal on January 15, 2021

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?

One Answer

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);

Correct answer by lendegroot on January 15, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP