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.

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:closed
  • Created a year ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Falke-Designcommented, May 2, 2022

Is no problem of Leaflet. Leaflet.Sleep has many usages of off() after once(), which will always throw listener not found because once has already removed the listener.

1reaction
Makin-Thingscommented, Apr 21, 2022

Thanks, I can confirm that the fix works for me. Closing.

Read more comments on GitHub >

github_iconTop 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 >

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