Open bencote opened 1 year ago
It seems that the slice method is throwing an error because the matrix3d style is empty. Wrapping the code in a try/catch block is currently suppressing the error, but the code is still considered broken since it relies on accessing a property of an undefined value.
To address the issue, you can modify the code to handle the case when the matrix3d style is empty or undefined.
I'm also getting this slice error in DistortableImageOverlay.js file.
TypeError: Cannot read properties of undefined (reading 'slice') at NewClass.getAngle (DistortableImageOverlay.js:321:1) at NewClass._reset (DistortableImageOverlay.js:457:1) at NewClass.setBounds (ImageOverlay.js:144:1) at NewClass._initImageDimensions (DistortableImageOverlay.js:128:1) at HTMLImageElement.eval (DistortableImageOverlay.js:40:1) at HTMLImageElement.handler (DomEvent.js:108:1)
getAngle(unit = 'deg') { var matrix = this.getElement().style[L.DomUtil.TRANSFORM] .split('matrix3d')[1] .slice(1, -1) .split(','); ...... },
At the end matrix is not undefined and my code will work just fine, but this error is annoying because it'll pop up every time. Is there something I could do in my code to prevent this?
I can get the getAngle command to throw an error when I scale the image very small on the map. In the code below, the slice command error because the matrix3d style is empty. I wrapped it in a try/catch to suppress the error but i still consider the code to be broken...
Describe the bug: debug output:
TypeError: Cannot read properties of undefined (reading 'slice') at NewClass.getAngle (DistortableImageOverlay.js:355:28) at NewClass._reset (DistortableImageOverlay.js:493:1) at NewClass.setBounds (ImageOverlay.js:144:9) at NewClass._initImageDimensions (DistortableImageOverlay.js:140:15) at HTMLImageElement. (DistortableImageOverlay.js:47:36)
at HTMLImageElement.handler (DomEvent.js:108:13)
Reproduce the behavior: Steps to reproduce the behavior. (ex. 1. Go to... 2. Click on... 3. See error...)
Browser, version, and operating system: