Unexpected behavior when repeatedly calling map.setZoom with the same zoom level
See original GitHub issueSteps to reproduce Steps to reproduce the behavior:
- go to this JS Fiddle with an example of the issue
- hit the button three times
- the first time, the map zooms to the specified zoom level
- the second time, it zooms to the feature’s bounds
- the third time, it zooms back out to the specified zoom level
- the pattern continues each time the button is pressed.
Expected behavior I expect that calling map.setZoom repeatedly with the same argument will result in no change if the zoom is already at that value
Current behavior The map is zooming back and forth between the desired zoom level and the bounds of the feature
Environment
- Leaflet version: 1.6.0
- Browser (with version): Firefox 72.0.2
- OS/Platform (with version): MacOS 10.14.6
Additional context I also noted this behavior if you replace lines 12 & 13 with this:
map.fitBounds(circle.getBounds());
map.fitBounds(circle.getBounds(), {maxZoom: 14});
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top Results From Across the Web
Unexpected behavior when repeatedly calling map.setZoom ...
Here is a js fiddle which demonstrates the behavior I'm talking about. Hitting the "Zoom it" button 3-5 times shows first a zoom...
Read more >map.bounds_changed event fires repeatedly when the map is ...
You can work around this behavior with a setTimeout() call to only act on the event once after it stops firing. This fires...
Read more >Maps JavaScript API | Google Developers
When using v=beta , can be accessed by calling const {Map} = await google.map. ... The allowed values are restricted depending on the...
Read more >question
Unexpected behavior when repeatedly calling map.setZoom with the same zoom level (Leaflet.js). Mar 11, 2020. 1. Writing set of functions that will use...
Read more >Four causes for 'Zoom fatigue' and their solutions
Another source of stress is that, depending on your monitor size and whether you're using an external monitor, faces on videoconferencing calls ...
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
Workaround: use option
{animate:false}
.Note that you need to disable animation for both command, otherwise you will get funny effect.
I still tend to think that this is leaflet flaw