Skip to content

Problem with Rails Stimulus controller use #491

@MtnBiker

Description

@MtnBiker

Rails Stimulus doesn't deal with ol/control/Control, therefore going back to old style which seems to work.

Using node_modules;

import ol from 'openlayers/dist/ol-debug.js'

and then have to use for example var baseLayers = new ol.layer.Group

But
import LayerSwitcher from 'ol-layerswitcher/dist/ol-layerswitcher.js'

has this error

 ✘ [ERROR] Could not resolve "ol/control/Control"

     node_modules/ol-layerswitcher/dist/ol-layerswitcher.js:2:97:
       2 │ ...rts = factory(require('ol/control/Control'), require('ol/Observa...
         ╵                          ~~~~~~~~~~~~~~~~~~~~

   You can mark the path "ol/control/Control" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

 ✘ [ERROR] Could not resolve "ol/Observable"

     node_modules/ol-layerswitcher/dist/ol-layerswitcher.js:2:128:
       2 │ ...ntrol/Control'), require('ol/Observable'), require('ol/layer/Gro...
         ╵                             ~~~~~~~~~~~~~~~

   You can mark the path "ol/Observable" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

 ✘ [ERROR] Could not resolve "ol/layer/Group"

     node_modules/ol-layerswitcher/dist/ol-layerswitcher.js:2:154:
       2 │ ...l/Control'), require('ol/Observable'), require('ol/layer/Group')) :
         ╵                                                   ~~~~~~~~~~~~~~~~

   You can mark the path "ol/layer/Group" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.

Any work arounds or? LayerSwitcher is what I need for my app. Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions