zoom to the nearest round zoom with pinch or dblclick
This commit is contained in:
parent
fc655e45c7
commit
5912c365b7
@ -17,7 +17,8 @@ L.Map.DoubleClickZoom = L.Handler.extend({
|
|||||||
|
|
||||||
_onDoubleClick: function (e) {
|
_onDoubleClick: function (e) {
|
||||||
var map = this._map,
|
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') {
|
if (map.options.doubleClickZoom === 'center') {
|
||||||
map.setZoom(zoom);
|
map.setZoom(zoom);
|
||||||
|
@ -103,7 +103,7 @@ L.Map.TouchZoom = L.Handler.extend({
|
|||||||
var map = this._map,
|
var map = this._map,
|
||||||
oldZoom = map.getZoom(),
|
oldZoom = map.getZoom(),
|
||||||
zoomDelta = this._zoom - oldZoom,
|
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);
|
map._animateZoom(this._center, finalZoom, true);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user