Setting maxbounds on map creation throws warning
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 Steps to reproduce the behavior:
- create a map while setting maxbounds
- on loading the map it throws a warning
listener not found
_off @ leaflet.js:590
off @ leaflet.js:499
setMaxBounds @ leaflet.js:3422
initialize @ leaflet.js:3114
NewClass @ leaflet.js:302
createMap @ leaflet.js:4717
(anonymous) @ VM8861 about:srcdoc:231
Expected behavior
It should not throw a warning
Current behavior
Environment
- Leaflet version: 1.8.0 (the identical code with 1.7.1 doesn’t throw a warning)
- Browser (with version): Latest Chrome and Firefox
- OS/Platform (with version): Windows 10
Additional context
Minimal example reproducing the issue
var map = new L.Map('leaflet', {
layers: [
new L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
'attribution': 'Map data © <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'
})
],
center: [-35.149, 149.08013],
maxBounds: [
[0, 101.25],
[-55.77657, 168.75],
],
zoom: 7
});
Please create an example using https://leafletjs.com/edit.html or any other jsfiddle-like site.
- this example is as simple as possible
- this example does not rely on any third party code
Issue Analytics
- State:
- Created a year ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Setting maxbounds on map creation throws warning - IssueHint
Steps to reproduce the behavior: create a map while setting maxbounds; on loading the map it throws a warning. listener not found _off...
Read more >Fix "listener not found" warning when setting maxBounds #8168
mourner merged 2 commits into main from fix-map-bounds-warning on Apr 20 ... Setting maxbounds on map creation throws warning #8173.
Read more >Set boundaries with leaflet maxbounds but doesn't work
Hi i try to set the maxbaounds in a leaflet map but it doesn't work. My first questions is maxbounds stop to pan...
Read more >Map Tutorial using LeafletJS ~ 04 Map bounds and ... - YouTube
In this series we will be creating a fantasy map for my RhinoDroid comic strip using LeafletJS mapping API.DOWNLOADS:These are the files and ......
Read more >Setting bounds and making map bounce back if moved away
[Final Answer]. I bet you can easily resolve this by setting the map's maxBounds equal to its initial bounds immediately upon loading. :)....
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
Is no problem of Leaflet. Leaflet.Sleep has many usages of
off()
afteronce()
, which will always throwlistener not found
becauseonce
has already removed the listener.Thanks, I can confirm that the fix works for me. Closing.