Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with setZoom and setMinZoom #9226

Open
4 tasks done
shift0965 opened this issue Jan 22, 2024 · 1 comment
Open
4 tasks done

Problem with setZoom and setMinZoom #9226

shift0965 opened this issue Jan 22, 2024 · 1 comment
Labels
bug needs triage Triage pending

Comments

@shift0965
Copy link

Checklist

  • I've looked at the documentation to make sure the behavior isn't documented and expected.
  • I'm sure this is an issue with Leaflet, not with my app or other dependencies (Angular, Cordova, React, etc.).
  • I've searched through the current issues to make sure this hasn't been reported yet.
  • I agree to follow the Code of Conduct that this project adheres to.

Steps to reproduce

map.setZoom(8)
console.log(map.getZoom()); // 8
map.setMinZoom(11);
console.log(map.getZoom()); // 8
map.setZoom(11);
console.log(map.getZoom()); // 8

Expected behavior

when use called setMinZoom the zoom level should be set to max(current zoom, min zoom)

Current behavior

setView(center, zoom, options) {

the _resetView function is not being called, so the zoom level is the same as previous level after setZoom() and setMinZoom() but this.options.minZoom have been changed

Minimal example reproducing the issue

https://plnkr.co/edit/lEWgKwR9hFuxcqQi?preview

Environment

  • Leaflet version: 1.8.0
  • Browser (with version): chrome
  • OS/Platform (with version):
@shift0965 shift0965 added bug needs triage Triage pending labels Jan 22, 2024
@IvanSanchez
Copy link
Member

IvanSanchez commented Jan 22, 2024

when use called setMinZoom the zoom level should be set to max(current zoom, min zoom)

Not really.

When calling setMinZoom() or setZoom(), the expected behaviour is to start a zoom animation.

For technical reasons the animation starts at the next animation frame, and getZoom reports the current value instead of the desired value.

Note that your desired behaviour can be achieved when using the zoomAnimation map option with a value of false.

I do not think this is actionable. I'm also tempted to close this as a dupe of #4696 , which is meant to cover the issue of "current value" vs "desired value".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs triage Triage pending
Projects
None yet
Development

No branches or pull requests

2 participants