Merge pull request #1939 from jfirebaugh/zoom

Support center-oriented scroll/double-click zoom
This commit is contained in:
Vladimir Agafonkin 2013-08-06 01:55:08 -07:00
commit 8611e22005
2 changed files with 15 additions and 4 deletions

View File

@ -8,15 +8,22 @@ L.Map.mergeOptions({
L.Map.DoubleClickZoom = L.Handler.extend({
addHooks: function () {
this._map.on('dblclick', this._onDoubleClick);
this._map.on('dblclick', this._onDoubleClick, this);
},
removeHooks: function () {
this._map.off('dblclick', this._onDoubleClick);
this._map.off('dblclick', this._onDoubleClick, this);
},
_onDoubleClick: function (e) {
this.setZoomAround(e.containerPoint, this._zoom + 1);
var map = this._map,
zoom = map.getZoom() + 1;
if (map.options.doubleClickZoom === 'center') {
map.setZoom(zoom);
} else {
map.setZoomAround(e.containerPoint, zoom);
}
}
});

View File

@ -51,7 +51,11 @@ L.Map.ScrollWheelZoom = L.Handler.extend({
if (!delta) { return; }
map.setZoomAround(this._lastMousePos, zoom + delta);
if (map.options.scrollWheelZoom === 'center') {
map.setZoom(zoom + delta);
} else {
map.setZoomAround(this._lastMousePos, zoom + delta);
}
}
});