Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing _resize function in MaplibreGLLayer.js module #152

Open
NatEvatt opened this issue Nov 7, 2022 · 1 comment
Open

Missing _resize function in MaplibreGLLayer.js module #152

NatEvatt opened this issue Nov 7, 2022 · 1 comment
Labels

Comments

@NatEvatt
Copy link

NatEvatt commented Nov 7, 2022

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.

      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

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.

@gavinr
Copy link
Contributor

gavinr commented Nov 8, 2022

Thank you for the report!

To add an additiaonl debugging data point:

@gavinr gavinr added the bug label Nov 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants