esri-leaflet: esri-leaflet fails when calling fitbounds

  • Browser and version: Chrome latest

  • Version of Leaflet (L.version): 1.3.0

  • Version of esri Leaflet (L.esri.VERSION): 2.1.4

Steps to reproduce the error: It’s hard to say, since I couldn’t create a minimal reproduction, but it has to do with fitbounds method called when the zoom level is already set to the same zoom.

What happens is [X]. I get an ugly error message I was expecting [Y]. No error message should appear

Here is the error message:

TypeError: Cannot read property 'min' of undefined
    at NewClass._isValidCell (esri-leaflet-debug.js:3028)
    at NewClass._addCells (esri-leaflet-debug.js:2997)
    at NewClass._update (esri-leaflet-debug.js:2980)
    at NewClass.fire (leaflet-src.js:593)
    at NewClass.panBy (leaflet-src.js:3276)
    at NewClass._tryAnimatedPan (leaflet-src.js:4500)
    at NewClass.setView (leaflet-src.js:3154)
    at NewClass.fitBounds (leaflet-src.js:3253)
    at DataContainerService.push../sources/application/services/data-container.service.ts.DataContainerService.setData (data-container.service.ts:45)
    at DataContainerService.<anonymous> (data-container.service.ts:97)

Here’s a screenshot of the debug I tried, but I’m clueless to what should be the right values, maybe you guys can look at it and let me know if you need more info, I have no problem reproducing it. image

I can probably also upload a beta site with the source maps if you’d like to debug it yourself. The layers are extremely valuable to my users but I can’t have my site crashing on a third party plug-in…

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (6 by maintainers)

Most upvoted comments

This issue still persists, is there a solution for this error?

I can confirm the following code seems to solve the issue:

_isValidCell: function (coords) {
    var crs = this._map.options.crs;

    if (!crs.infinite) {
      // don't load cell if it's out of bounds and not wrapped
      var cellNumBounds = this._cellNumBounds;
      if (!cellNumBounds) { // you can probably check for null or undefined.
           return false;
      }
      if (
        (!crs.wrapLng && (coords.x < cellNumBounds.min.x || coords.x > cellNumBounds.max.x)) ||
        (!crs.wrapLat && (coords.y < cellNumBounds.min.y || coords.y > cellNumBounds.max.y))
      ) {
        return false;
      }
    }