From c33420742a43378cf0b43878b316d80ff80fd828 Mon Sep 17 00:00:00 2001 From: DubrovinPavel Date: Thu, 27 Apr 2017 14:16:11 +0500 Subject: [PATCH] Add fractional zoom levels support --- bower.json | 2 +- package.json | 2 +- src/L.Control.Zoomslider.js | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index c23ea05..6a4f180 100644 --- a/bower.json +++ b/bower.json @@ -18,6 +18,6 @@ "tests" ], "dependencies": { - "leaflet": "~0.7.1" + "leaflet": "1.0.1" } } diff --git a/package.json b/package.json index 993d00b..67b2c96 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ ], "description": "A zoom slider widget for Leaflet", "dependencies": { - "leaflet": "~0.7.1" + "leaflet": "1.0.1" }, "devDependencies": { "mocha": "~1.9.0", diff --git a/src/L.Control.Zoomslider.js b/src/L.Control.Zoomslider.js index 606cd1d..ed8aff6 100644 --- a/src/L.Control.Zoomslider.js +++ b/src/L.Control.Zoomslider.js @@ -160,21 +160,23 @@ }, _zoomIn: function (e) { - this._map.zoomIn(e.shiftKey ? 3 : 1); + var delta = this._map.options.zoomDelta || 0; + this._map.zoomIn(e.shiftKey ? 3 * delta : delta); }, _zoomOut: function (e) { - this._map.zoomOut(e.shiftKey ? 3 : 1); + var delta = this._map.options.zoomDelta || 0; + this._map.zoomOut(e.shiftKey ? 3 * delta : delta); }, _zoomLevels: function () { - var zoomLevels = this._map.getMaxZoom() - this._map.getMinZoom() + 1; + var zoomLevels = (this._map.getMaxZoom() - this._map.getMinZoom()) / this._map.options.zoomDelta + 1; return zoomLevels < Infinity ? zoomLevels : 0; }, _toZoomLevel: function (value) { - return value + this._map.getMinZoom(); + return value * this._map.options.zoomDelta + this._map.getMinZoom(); }, _toValue: function (zoomLevel) { - return zoomLevel - this._map.getMinZoom(); + return (zoomLevel - this._map.getMinZoom()) / this._map.options.zoomDelta; }, _updateSize: function () {