Leaflet.MagnifyingGlass icon indicating copy to clipboard operation
Leaflet.MagnifyingGlass copied to clipboard

Proposal for new method: setFixedZoom(fixedZoom)

Open StefanBrand opened this issue 5 years ago • 0 comments

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)
      /* ... */
    }
})

StefanBrand avatar Jul 19 '19 08:07 StefanBrand