walkermatt / ol-layerswitcher

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

Class constructor Control cannot be invoked without 'new' #389

Closed hctan89 closed 3 years ago

hctan89 commented 3 years ago

Using this library(v3.8.3) with OL(v6.4.3) in my Angular project(v10.2.0). Unable to load the layer-switcher due to the following error.

ERROR TypeError: Class constructor Control cannot be invoked without 'new' at new LayerSwitcher (ol-layerswitcher.js:168) at livemap.component.ts:150 at ZoneDelegate.invokeTask (zone-evergreen.js:399) at Object.onInvokeTask (core.js:27533) at ZoneDelegate.invokeTask (zone-evergreen.js:398) at Zone.runTask (zone-evergreen.js:167) at invokeTask (zone-evergreen.js:480) at ZoneTask.invoke (zone-evergreen.js:469) at timer (zone-evergreen.js:2552)

This is the part at line 150 for my livemap.component.ts

 const layerSwitcher = new LayerSwitcher({
      tipLabel: 'Layer Switcher', // Optional label for button
      groupSelectStyle: 'children' // Can be 'children' [default], 'group' or 'none'
  });

Thanks and appreciate any kind assistance.

walkermatt commented 3 years ago

An initial Google turns up this issue which sounds similar:

https://github.com/Enngage/ngx-paypal/issues/135

The later comments mention the new Ivy complication pipeline and details of compatibility and debugging options https://angular.io/guide/ivy.

If you've not already, maybe first try disabling Ivy; if that works and you wish to use Ivy then try the linked debugging/ compatibility options?