From 5912c365b7092e8e622e2cbba01cc573b97a5987 Mon Sep 17 00:00:00 2001 From: Vladimir Agafonkin Date: Fri, 24 Jan 2014 16:24:27 +0200 Subject: [PATCH] zoom to the nearest round zoom with pinch or dblclick --- src/map/handler/Map.DoubleClickZoom.js | 3 ++- src/map/handler/Map.TouchZoom.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/map/handler/Map.DoubleClickZoom.js b/src/map/handler/Map.DoubleClickZoom.js index 6399734e..8f381406 100644 --- a/src/map/handler/Map.DoubleClickZoom.js +++ b/src/map/handler/Map.DoubleClickZoom.js @@ -17,7 +17,8 @@ L.Map.DoubleClickZoom = L.Handler.extend({ _onDoubleClick: function (e) { var map = this._map, - zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1); + oldZoom = map.getZoom(), + zoom = e.originalEvent.shiftKey ? Math.ceil(oldZoom) - 1 : Math.floor(oldZoom) + 1; if (map.options.doubleClickZoom === 'center') { map.setZoom(zoom); diff --git a/src/map/handler/Map.TouchZoom.js b/src/map/handler/Map.TouchZoom.js index ab90795e..32e9d915 100644 --- a/src/map/handler/Map.TouchZoom.js +++ b/src/map/handler/Map.TouchZoom.js @@ -103,7 +103,7 @@ L.Map.TouchZoom = L.Handler.extend({ var map = this._map, oldZoom = map.getZoom(), zoomDelta = this._zoom - oldZoom, - finalZoom = map._limitZoom(oldZoom + (zoomDelta > 0 ? Math.ceil(zoomDelta) : Math.floor(zoomDelta))); + finalZoom = map._limitZoom(zoomDelta > 0 ? Math.ceil(this._zoom) : Math.floor(this._zoom)); map._animateZoom(this._center, finalZoom, true); },