Removing map that has a tileLayer with minZoom set causes an error - undefined is not an object (evaluating 'el.style')
See original GitHub issue- I’ve looked at the documentation to make sure the behavior is documented and expected
- I’m sure this is a Leaflet code issue, not an issue with my own code nor with the framework I’m using (Cordova, Ionic, Angular, React…)
- I’ve searched through the issues to make sure it’s not yet reported
Steps to reproduce https://codesandbox.io/s/ywn94996wj
- Zoom out to the point where the high res tileLayer (url set to cloudfront) disappears due to it’s minZoom setting.
- Click the Hide button.
- Error (see image below)
- Remove
minZoom: 18
- Repeat steps 1 & 2 above
- No error
Expected behavior When using a tileLayer with minZoom set and the map zoomed out beyond the value of minZoom, removing the map should not cause an error
Current behavior When using a tileLayer with minZoom set and the map zoomed out beyond the value of minZoom, removing the map causes an error
Environment
- Leaflet version: 1.4.0
- Browser (with version): Safari 11.0.1
- OS/Platform (with version): Mac OS Sierra 10.12.6
Additional context Uncovered while using ReactLeaflet, initial bug report here - https://github.com/PaulLeCam/react-leaflet/issues/551. Further investigation revealed that it appears to be a Leaflet issue.
Minimal example reproducing the issue
https://codesandbox.io/s/ywn94996wj
- this example is as simple as possible
- this example does not rely on any third party code
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
TypeError: undefined is not an object (evaluating 'items.map')
After receiving items, the following error occurs. At the moment I'm just learning and have looked at other answers on this topic, nothing...
Read more >Leaflet 1.7 documentation - DevDocs
Returns the minimum zoom level of the map (if set in the minZoom option of the map or of any layers), or 0...
Read more >typeerror: cannot read properties of undefined (reading 'lat')
If you want to prevent Map to be "undefined". First declare your map variable as public js variable (in the head of your...
Read more >Create Interactive Web Maps with the JavaScript 'Leaflet' Library
If the error "Cannot read property 'appendChild' of undefined" occurs, make sure the pane being used for used for display has already been...
Read more >Leaflet - a JavaScript library for interactive maps - GitHub Pages
setView( <LatLng> center, <Number> zoom?, <zoom/pan options> options? ) this, Sets the view of the map (geographical center and zoom) with the given...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is pretty bothersome, as it will kill an unsuspecting (=not expecting errors from a normal operation) React app hiding/removing a React Leaflet Map: https://github.com/PaulLeCam/react-leaflet/issues/625
This is the simplest reproduction I can think of in case it is any help: https://codepen.io/tkurki/pen/XWWNBmr
Not able to reproduce using v1.8.0: https://plnkr.co/edit/SudJnPOVbG7Y901P?preview