question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic Layers crash when minZoom or maxZoom specified

See original GitHub issue

This may be related to https://github.com/Esri/esri-leaflet/issues/910, which is marked as resolved, but I’m seeing this using the demo below, which uses Leaflet 1.0.3 and EsriLeaflet 2.0.7

When using minZoom or maxZoom on a Dynamic Layer, I’m seeing a fatal error. To reproduce:

  • zoom in until the States layer becomes visible at level 7
  • zoom out to level 8 so it switches off
  • pan the map

I’m seeing Uncaught TypeError: Cannot read property 'removeLayer' of null, and the map becomes unresponsive to further panning.

<html>
<head>
  <meta charset=utf-8 />
  <title>Simple DynamicMapLayer</title>
  <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

  <!-- Load Leaflet from CDN-->
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css" />
  <script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet-src.js"></script>

  <!-- Load Esri Leaflet from CDN -->
  <script src="https://unpkg.com/esri-leaflet@2.0.7"></script>

  <style>
    body { margin:0; padding:0; }
    #map { position: absolute; top:20; bottom:0; right:0; left:0; }
  </style>
</head>
<body>
  <span id="zoom">Zoom in until the States become visible at level 7, then zoom out, and pan</span>
  <div id="map"></div>
<script>
  var map = L.map('map').setView([37.71, -99.88], 4);

  map.on("zoomend", function(){
    document.getElementById("zoom").innerHTML = "Current zoom level is " + this.getZoom();
  })

  L.esri.basemapLayer('Gray').addTo(map);

  L.esri.dynamicMapLayer({
    url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/',
    layers: [5],
    useCors: false,
    minZoom: 7
  }).addTo(map);
</script>

</body>
</html>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jgravoiscommented, Mar 21, 2017

this fix is included in v2.0.8

0reactions
jordanparfittcommented, Jun 3, 2022

My bower file was just jacked up. It works great. Thanks for the quick response.

On Fri, May 19, 2017 at 12:32 PM, john gravois notifications@github.com wrote:

Did the nullify part get inserted into 2.0.8?

yup. its here https://github.com/Esri/esri-leaflet/blob/v2.0.8/src/Layers/RasterLayer.js#L240

i just retested @slead https://github.com/slead’s repro case here (and yours in #910 (comment) https://github.com/Esri/esri-leaflet/issues/910#issuecomment-274619531) with v2.0.8 and everything looked fine to me. if you are seeing errors, please feel free to log a new issue. i’d be happy to check into it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Esri/esri-leaflet/issues/927#issuecomment-302778431, or mute the thread https://github.com/notifications/unsubscribe-auth/ABLNpkFJSRoDyHLQuTf-96FcYkz303l3ks5r7eA7gaJpZM4MCiId .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Change dynamically created layer's minZoom after render
I tried couple of things: map.getLayer('my_custom_layer'); // this gets the layer map.getLayer('my_custom_layer ...
Read more >
Memory issue when trying to use minZoom on XYZ source
maxZoom works just fine. I was originally using OpenLayers in React, but after running into this issue, I stripped it down as much...
Read more >
Improve the performance of Mapbox GL JS maps | Help
Add explicit minzoom and maxzoom values to style layers to prevent filters from being used for evaluation at zoom levels where all geometries...
Read more >
freedog - .. - mapbox-gl - CHANGELOG.md - GitLab
Fixed a bug where ImageSource and dynamically loaded icons didn't work in ... Now you can directly mutate the minzoom and maxzoom layer...
Read more >
Controlling Zoom and Pan | Maps JavaScript API
The usage of a map on a web page may require specific options to control the ... such as gestureHandling , minZoom ,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found