Viglino / ol-ext

Cool extensions for Openlayers (ol) - animated clusters, CSS popup, Font Awesome symbol renderer, charts for statistical map (pie/bar), layer switcher, wikipedia layer, animations, canvas filters.
https://viglino.github.io/ol-ext/
Other
1.25k stars 463 forks source link

GeoImage constructor setScale() call TypeError #671

Closed DmitrySavritsky closed 3 years ago

DmitrySavritsky commented 3 years ago

Hello, I moved from 3.2.4 to 3.2.7 version of ol-ext package and it seems that there is something wrong with the setScale function of GeoImage class. Target.js:103 Uncaught TypeError: Cannot read properties of undefined (reading 'change') at ol_source_GeoImage../node_modules/ol/events/Target.js.Target.dispatchEvent (Target.js:103) at ol_source_GeoImage../node_modules/ol/Observable.js.Observable.changed (Observable.js:48) at ol_source_GeoImage../node_modules/ol-ext/source/GeoImage.js.ol_source_GeoImage.setScale (GeoImage.js:159) You changed "this.scale = opt_options.imageScale; " to "this.setScale(opt_options.imageScale); " in the constructor and I think that call of "this.changed(); " inside the setScale() function is the cause of this TypeError. Am I right?

Viglino commented 3 years ago

It seems the setScale is called before the Object initialization and the changed function is not completely defined. The parameters initialization should be set after the object initialization (parent.call).

Viglino commented 3 years ago

I've pushed a new version that should fix the error. Can you test it? Just copy the GeoImage file https://github.com/Viglino/ol-ext/blob/master/src/source/GeoImage.js and replace the one in your node_module/ol-ext/source

DmitrySavritsky commented 3 years ago

Yes, there is no errors in new version. It will be great if you'll update the npm package with this fix.

Viglino commented 3 years ago

I've published the 3.2.8 on npm.