Leaflet.MagnifyingGlass
Leaflet.MagnifyingGlass copied to clipboard
Proposal for new method: setFixedZoom(fixedZoom)
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? :slightly_smiling_face:
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)
/* ... */
}
})