I was wondering if there is a LayerSwitcher control in OpenLayers 3?

I read that ol3 is a complete rewrite. But I can't seem to find the equivalent of LayerSwitcher from http://openlayers.org/en/latest/apidoc/ol.control.html. I don't see how one can turn on and off layers without this control. Is LayerSwitcher renamed to something else, missing or is the documentation incomplete?

If OpenLayers3 does not have LayerSwitcher, does anyone know of an example that implements a custom control like the old LayerSwitcher?


This question was asked on Twitter recently https://twitter.com/RemiBovard/status/525028570780139520

If you follow the answer, at the moment, integrating layer switcher in the core is not the priority but there is an available component at https://github.com/walkermatt/ol3-layerswitcher

You can also take a look on "The book of OpenLayers" samples (by @acanimal) for some custom legend implementations.

  • 6
    ol version 3.9.0 and still no native switcher. Come on ol devs!!! Anyway, people also check this http://wp.ellevator.net/quick-n-dirty-layer-switcher-for-openlayers-3/2/ while I seriously think switching to leaflet
    – slevin
    Sep 27 '15 at 14:52

there is a project on github running but it is in a very early stage. It is using extjs for the tree panel. check it here extjs_ol3_layercontrol


You also might want to have a look at this extension which implements a layer switching control with many useful additional features such as toggling whole layer groups on and off, controlling layer visibility via a slider and switching the drawing order of the layers.


I have a solution for OL 3+ versions the current one I have created on ol 6+ but will work with 3+ versions as well with minor tweaks. Please find this code here.

It's a small example to create ol library style layer switcher which can be used as individual control or you can directly utilize interaction where ever you want.


You can also look for the layer-switcher JavaScript which has been implemented for Openlayers v3.x in this example Closest Distance Map.

You can also download it and implement in your project.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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