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

Proposal for new method: setFixedZoom(fixedZoom) #14

Open
StefanBrand opened this issue Jul 19, 2019 · 0 comments
Open

Proposal for new method: setFixedZoom(fixedZoom) #14

StefanBrand opened this issue Jul 19, 2019 · 0 comments

Comments

@StefanBrand
Copy link

I've come up with a simple addition to L.MagnifyingGlass: A setFixedZoom method. Usually my magnifying glass has zoomOffset = 0, but when the main map reaches its maxZoom = 18, I tell my magnifying glass to zoom in further to fixedZoom = 19 (whole application code below).

setFixedZoom: function(fixedZoom) {
    this._fixedZoom = (fixedZoom != -1);
    this.options.fixedZoom = fixedZoom;
    this._updateZoom()
}

What do you think? Shall I create a PR? 🙂


L.DomEvent.on(glass_map.getContainer(), 'mousewheel', e => {
    if (map.getZoom() === 18 && e.deltaY < 0) { // zoom in
      magnifying_glass.setFixedZoom(19)
      /* ... */
    }
    if (magnifying_glass.options.fixedZoom !== -1 && e.deltaY > 0) { // zoom out
      L.DomEvent.stopPropagation(e) // avoid zoom out of main map
      magnifying_glass.setFixedZoom(-1)
      /* ... */
    }
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant