Norkart / Leaflet-MiniMap

A minimap control plugin for Leaflet
BSD 2-Clause "Simplified" License
395 stars 125 forks source link

Enhancement: Option to disable zoom/pan #77

Closed landwire closed 9 years ago

landwire commented 9 years ago

Hi there, it would be nice to have the option to disable zoomon the minimap. Everytime I scroll over the map with my mouse (i.e I scroll down the page and my pointer happens to come over the minimap), the minimap changes zoom and the big map obviously too.

I also would like to be able to disable "dragging" the map.

Thanks, Sascha

robpvn commented 9 years ago

This could indeed be useful for some cases, and is only partially covered by options we have available today. Instinctively I don't think this should be too hard to implement.

mletic commented 9 years ago

You can add two new optional parameters when creating the MiniMap. Something like:

this.miniMapCntrl = new L.Control.MiniMap(this.pilotLayer.layer, { toggleDisplay: true, disableZoom: true, disableDragging: true, zoomLevelFixed: 1 });

And just add this in your Control.MiniMap.js:

if (this.options.disableDragging) { this._miniMap.dragging.disable(); } if (this.options.disableZoom) { this._miniMap.touchZoom.disable(); this._miniMap.doubleClickZoom.disable(); this._miniMap.scrollWheelZoom.disable(); }

This should do the trick, I just don't have the time to push this on github.