Esri / Esri/esri-leaflet-vector

Missing _resize function in MaplibreGLLayer.js module

Open
#152 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
72
Forks
54
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

I am currently in the process of moving my production app from `L.esri.BasemapLayer` to your vector tiles plugin and running into an issue. When calling the map.invalidateSize() function, I run into a `leaflet-src.js:588 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')`

When I jump into dev tools, this `fire` method within `invalidateSize` is passing the type `resize` to `fire`
```
return this.fire('resize', {
oldSize: oldSize,
newSize: newSize
});
```

Within the `fire` method, a `listeners` object is created, which pulls from `_events` by `type`, in this case, `resize`. Unfortunately, in the case of `resize` there is no function attached to that listener.
```
if (this._events) {
var listeners = this._events[type];

if (listeners) {
this._firingCount = (this._firingCount + 1) || 1;
for (var i = 0, len = listeners.length; i < len; i++) {
var l = listeners[i];
l.fn.call(l.ctx || this, event);
}

this._firingCount--;
}
}
```

I believe that I was able to trace the issue back to the `MaplibreGLLayer.js` module where the `getEvents` function references the "private" function `_resize`. However, this function does not exist in the `MaplibreGLLayer.js`.
```getEvents: function () {
return {
...
resize: this._resize
};
},
```

In order to get rid of my error, i have put in a dummy function for `_resize` and with this, my code works as expected. This function is obviously not doing anything very helpful, but I am looking to you all for what the expected functionality is.
```
_resize: function (e) {
this._resizing = true;
},
```

### Reproduction

https://codepen.io/natevatt-the-sasster/pen/YzLMJwg

open dev tools. Click button "click me".

### Logs

```shell
leaflet-src.js:588 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'call')
at NewClass.fire (leaflet-src.js:588:1)
at NewClass.invalidateSize (leaflet-src.js:3575:1)
at Object.invalidateModalMapSize (modalMap.js:61:1)
...
```
```

### System Info

```shell
- leaflet: 1.7.1
- maplibre-gl: 2.4.0
- esri-leaflet: 3.0.8
- esri-leaflet-vector: 4.0.0
```

### Additional Information

I am using Gulp to bundle for my production app.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.