walkermatt / ol-layerswitcher

Layer control for OpenLayers
MIT License
384 stars 176 forks source link

ol-layerswitcher with OpenLayers 7 fails #496

Closed pggsn closed 1 year ago

pggsn commented 1 year ago

Hi,

I'm trying to include the ol-layerswitcher (v4.1.1) in my OpenLayers 7 map project. However, the layer switcher button does not appear and in the devtools console, this message appears:

Uncaught TypeError: Cannot read properties of undefined (reading 'control') at ol-layerswitcher.js:4:44 at ol-layerswitcher.js:5:2

Is the latest version of ol-layerswitcher not compatible with the latest ol version?

Thank you!

walkermatt commented 1 year ago

Hi @pggsn :wave: I've used v4.1.1 with ol 7. Here's a sandbox which I've just pulled together: https://codesandbox.io/s/ol-7-3-0-ol-layerswitcher-4-1-1-8it72j which will hopefully help.

pggsn commented 1 year ago

Thank you!! That helps 😍