From 57a86353cd354b13de056a2ce305d1296c6c0685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 20 Feb 2013 16:47:22 +0100 Subject: [PATCH 01/15] zoomFactor defaults to 2 --- examples/wms-custom-proj.js | 14 -------------- src/ol/map.js | 4 ++-- src/ol/view2d.js | 6 ++---- test/spec/ol/map.test.js | 2 +- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/examples/wms-custom-proj.js b/examples/wms-custom-proj.js index 19d03ca493..6aae577534 100644 --- a/examples/wms-custom-proj.js +++ b/examples/wms-custom-proj.js @@ -19,19 +19,6 @@ var epsg21781 = new ol.Projection('EPSG:21781', ol.ProjectionUnits.METERS, new ol.Extent(485869.5728, 76443.1884, 837076.5648, 299941.7864)); ol.projection.addProjection(epsg21781); -// We could give the single image source a set of resolutions. This prevents the -// source from requesting images of arbitrary resolutions. To try it, uncomment -// the block below and the resolutions option in the SingleImageWMS config. -/* -var projectionExtent = epsg21781.getExtent(); -var maxResolution = Math.max(projectionExtent.getWidth(), - projectionExtent.getHeight()) / 256; -var resolutions = new Array(10); -for (var i = 0; i < 10; ++i) { - resolutions[i] = maxResolution / Math.pow(2.0, i); -} -*/ - var extent = new ol.Extent(420000, 30000, 900000, 350000); var layers = new ol.Collection([ new ol.layer.TileLayer({ @@ -50,7 +37,6 @@ var layers = new ol.Collection([ }), new ol.layer.ImageLayer({ source: new ol.source.SingleImageWMS({ - //resolutions: resolutions, url: 'http://wms.geo.admin.ch/', attributions: [new ol.Attribution( '© ' + diff --git a/src/ol/map.js b/src/ol/map.js index 9dfcee6d75..771122e531 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -941,7 +941,7 @@ ol.Map.createControls_ = function(mapOptions) { mapOptions.zoomControl : true; if (zoomControl) { var zoomDelta = goog.isDef(mapOptions.zoomDelta) ? - mapOptions.zoomDelta : 4; + mapOptions.zoomDelta : 1; controls.push(new ol.control.Zoom({ delta: zoomDelta })); @@ -971,7 +971,7 @@ ol.Map.createInteractions_ = function(mapOptions) { mapOptions.doubleClickZoom : true; if (doubleClickZoom) { var zoomDelta = goog.isDef(mapOptions.zoomDelta) ? - mapOptions.zoomDelta : 4; + mapOptions.zoomDelta : 1; interactions.push(new ol.interaction.DblClickZoom(zoomDelta)); } diff --git a/src/ol/view2d.js b/src/ol/view2d.js index f80d3cf25c..9f8a82db1c 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -359,10 +359,8 @@ ol.View2D.createConstraints_ = function(view2DOptions) { maxResolution = Math.max( projectionExtent.maxX - projectionExtent.minX, projectionExtent.maxY - projectionExtent.minY) / ol.DEFAULT_TILE_SIZE; - // number of steps we want between two data resolutions - var numSteps = 4; - numZoomLevels = 29 * numSteps; - zoomFactor = Math.exp(Math.log(2) / numSteps); + numZoomLevels = 29; + zoomFactor = 2; } resolutionConstraint = ol.ResolutionConstraint.createSnapToPower( zoomFactor, maxResolution, numZoomLevels - 1); diff --git a/test/spec/ol/map.test.js b/test/spec/ol/map.test.js index 776d268400..c5e0ff2b30 100644 --- a/test/spec/ol/map.test.js +++ b/test/spec/ol/map.test.js @@ -121,7 +121,7 @@ describe('ol.Map', function() { var interactions = ol.Map.createInteractions_(options); expect(interactions.getLength()).toEqual(1); expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom); - expect(interactions.getAt(0).delta_).toEqual(4); + expect(interactions.getAt(0).delta_).toEqual(1); }); }); From 3ba9a4afd4779c40d9a38fdb6cdbceb60bc52dd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 20 Feb 2013 16:51:48 +0100 Subject: [PATCH 02/15] View2D zoom may animate pan --- src/ol/view2d.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 9f8a82db1c..2fcc1f9016 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -4,6 +4,7 @@ goog.provide('ol.View2D'); goog.provide('ol.View2DProperty'); +goog.require('goog.fx.easing'); goog.require('ol.Constraints'); goog.require('ol.Coordinate'); goog.require('ol.Extent'); @@ -312,12 +313,22 @@ ol.View2D.prototype.zoom_ = function(map, resolution, opt_anchor) { */ ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) { var currentResolution = this.getResolution(); - if (goog.isDef(currentResolution) && goog.isDef(opt_duration)) { + var currentCenter = this.getCenter(); + if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && + goog.isDef(opt_duration)) { map.requestRenderFrame(); map.addPreRenderFunction(ol.animation.zoom({ resolution: currentResolution, - duration: opt_duration + duration: opt_duration, + easing: goog.fx.easing.easeOut })); + if (goog.isDef(opt_anchor)) { + map.addPreRenderFunction(ol.animation.pan({ + source: currentCenter, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + } } var resolution = this.constraints_.resolution(currentResolution, delta); this.zoom_(map, resolution, opt_anchor); From 4d486601f98e8dc05b51f0aed72bdf54d6099f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Wed, 20 Feb 2013 16:52:20 +0100 Subject: [PATCH 03/15] MouseWheelZoom interaction animates zoom --- src/ol/interaction/mousewheelzoominteraction.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index a0e8f52cc9..9b49e01024 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -8,6 +8,12 @@ goog.require('ol.View2D'); goog.require('ol.interaction.Interaction'); +/** + * @define {number} Zoom duration. + */ +ol.interaction.ZOOM_DURATION = 200; + + /** * @constructor @@ -43,7 +49,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent = var view = map.getView(); goog.asserts.assert(view instanceof ol.View2D); map.requestRenderFrame(); - view.zoom(map, delta, anchor); + view.zoom(map, delta, anchor, ol.interaction.ZOOM_DURATION); mapBrowserEvent.preventDefault(); mouseWheelEvent.preventDefault(); } From faef495cfdf40973d6911e07edc85cb9c0536361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Thu, 21 Feb 2013 14:52:15 +0100 Subject: [PATCH 04/15] Debounce mousewheel zoom events --- src/objectliterals.exports | 1 - .../interaction/mousewheelzoominteraction.js | 91 ++++++++++++++++--- src/ol/map.js | 5 +- test/spec/ol/map.test.js | 27 +----- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/src/objectliterals.exports b/src/objectliterals.exports index 3f0a1e984d..36493574b1 100644 --- a/src/objectliterals.exports +++ b/src/objectliterals.exports @@ -7,7 +7,6 @@ @exportObjectLiteralProperty ol.MapOptions.keyboardPanOffset number|undefined @exportObjectLiteralProperty ol.MapOptions.layers ol.Collection|undefined @exportObjectLiteralProperty ol.MapOptions.mouseWheelZoom boolean|undefined -@exportObjectLiteralProperty ol.MapOptions.mouseWheelZoomDelta number|undefined @exportObjectLiteralProperty ol.MapOptions.renderer ol.RendererHint|undefined @exportObjectLiteralProperty ol.MapOptions.renderers Array.|undefined @exportObjectLiteralProperty ol.MapOptions.scaleLineControl boolean|undefined diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index 9b49e01024..b274dd7e35 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -4,30 +4,63 @@ goog.provide('ol.interaction.MouseWheelZoom'); goog.require('goog.events.MouseWheelEvent'); goog.require('goog.events.MouseWheelHandler.EventType'); +goog.require('goog.math'); +goog.require('ol.Coordinate'); goog.require('ol.View2D'); goog.require('ol.interaction.Interaction'); /** - * @define {number} Zoom duration. + * @define {number} Animation duration. */ -ol.interaction.ZOOM_DURATION = 200; +ol.interaction.MOUSEWHEELZOOM_ANIMATION_DURATION = 250; + + +/** + * @define {number} Maximum delta. + */ +ol.interaction.MOUSEWHEELZOOM_MAXDELTA = 1; + + +/** + * @define {number} Timeout duration. + */ +ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION = 80; /** * @constructor * @extends {ol.interaction.Interaction} - * @param {number} delta The zoom delta applied on each mousewheel. */ -ol.interaction.MouseWheelZoom = function(delta) { +ol.interaction.MouseWheelZoom = function() { + + goog.base(this); + /** * @private * @type {number} */ - this.delta_ = delta; + this.delta_ = 0; + + /** + * @private + * @type {?ol.Coordinate} + */ + this.lastAnchor_ = null; + + /** + * @private + * @type {number|undefined} + */ + this.startTime_ = undefined; + + /** + * @private + * @type {number|undefined} + */ + this.timeoutId_ = undefined; - goog.base(this); }; goog.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction); @@ -37,20 +70,52 @@ goog.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction); */ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + if (mapBrowserEvent.type == goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) { var map = mapBrowserEvent.map; var mouseWheelEvent = /** @type {goog.events.MouseWheelEvent} */ (mapBrowserEvent.browserEvent); goog.asserts.assert(mouseWheelEvent instanceof goog.events.MouseWheelEvent); - var anchor = mapBrowserEvent.getCoordinate(); - var delta = mouseWheelEvent.deltaY < 0 ? this.delta_ : -this.delta_; - // FIXME works for View2D only - var view = map.getView(); - goog.asserts.assert(view instanceof ol.View2D); - map.requestRenderFrame(); - view.zoom(map, delta, anchor, ol.interaction.ZOOM_DURATION); + + this.lastAnchor_ = mapBrowserEvent.getCoordinate(); + this.delta_ += mouseWheelEvent.deltaY / 3; + + if (!goog.isDef(this.startTime_)) { + this.startTime_ = goog.now(); + } + + var duration = ol.interaction.MOUSEWHEELZOOM_TIMEOUT_DURATION; + var timeLeft = Math.max(duration - (goog.now() - this.startTime_), 0); + + goog.global.clearTimeout(this.timeoutId_); + this.timeoutId_ = goog.global.setTimeout( + goog.bind(this.doZoom_, this, map), timeLeft); + mapBrowserEvent.preventDefault(); mouseWheelEvent.preventDefault(); } }; + + +/** + * @private + * @param {ol.Map} map Map. + */ +ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) { + var maxDelta = ol.interaction.MOUSEWHEELZOOM_MAXDELTA; + var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta); + + // FIXME works for View2D only + var view = map.getView(); + goog.asserts.assert(view instanceof ol.View2D); + + map.requestRenderFrame(); + view.zoom(map, -delta, this.lastAnchor_, + ol.interaction.MOUSEWHEELZOOM_ANIMATION_DURATION); + + this.delta_ = 0; + this.lastAnchor_ = null; + this.startTime_ = undefined; + this.timeoutId_ = undefined; +}; diff --git a/src/ol/map.js b/src/ol/map.js index 771122e531..0650f66a76 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1014,10 +1014,7 @@ ol.Map.createInteractions_ = function(mapOptions) { var mouseWheelZoom = goog.isDef(mapOptions.mouseWheelZoom) ? mapOptions.mouseWheelZoom : true; if (mouseWheelZoom) { - var mouseWheelZoomDelta = - goog.isDef(mapOptions.mouseWheelZoomDelta) ? - mapOptions.mouseWheelZoomDelta : 1; - interactions.push(new ol.interaction.MouseWheelZoom(mouseWheelZoomDelta)); + interactions.push(new ol.interaction.MouseWheelZoom()); } var shiftDragZoom = goog.isDef(mapOptions.shiftDragZoom) ? diff --git a/test/spec/ol/map.test.js b/test/spec/ol/map.test.js index c5e0ff2b30..38e5758437 100644 --- a/test/spec/ol/map.test.js +++ b/test/spec/ol/map.test.js @@ -85,28 +85,11 @@ describe('ol.Map', function() { }); describe('create mousewheel interaction', function() { - - beforeEach(function() { + it('creates mousewheel interaction', function() { options.mouseWheelZoom = true; - }); - - describe('default mouseWheelZoomDelta', function() { - it('create mousewheel interaction with default delta', function() { - var interactions = ol.Map.createInteractions_(options); - expect(interactions.getLength()).toEqual(1); - expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom); - expect(interactions.getAt(0).delta_).toEqual(1); - }); - }); - - describe('set mouseWheelZoomDelta', function() { - it('create mousewheel interaction with set delta', function() { - options.mouseWheelZoomDelta = 7; - var interactions = ol.Map.createInteractions_(options); - expect(interactions.getLength()).toEqual(1); - expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom); - expect(interactions.getAt(0).delta_).toEqual(7); - }); + var interactions = ol.Map.createInteractions_(options); + expect(interactions.getLength()).toEqual(1); + expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom); }); }); @@ -125,7 +108,7 @@ describe('ol.Map', function() { }); }); - describe('set mouseWheelZoomDelta', function() { + describe('set zoomDelta', function() { it('create double click interaction with set delta', function() { options.zoomDelta = 7; var interactions = ol.Map.createInteractions_(options); From 03ae41a68c466445f5a7ed7875a5f51f3f0806fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 17:59:43 +0100 Subject: [PATCH 05/15] Change View2D function names Also make the TouchZoom interaction no longer use a private View2D function. --- src/ol/control/zoomcontrol.js | 6 ++- src/ol/interaction/dblclickzoominteraction.js | 2 +- .../dragrotateandzoominteraction.js | 2 +- src/ol/interaction/keyboardzoominteraction.js | 3 +- .../interaction/mousewheelzoominteraction.js | 2 +- src/ol/interaction/touchzoominteraction.js | 4 +- src/ol/view2d.js | 42 +++++++++---------- 7 files changed, 32 insertions(+), 29 deletions(-) diff --git a/src/ol/control/zoomcontrol.js b/src/ol/control/zoomcontrol.js index ffacacf55f..63e3345cbf 100644 --- a/src/ol/control/zoomcontrol.js +++ b/src/ol/control/zoomcontrol.js @@ -70,7 +70,8 @@ ol.control.Zoom.prototype.handleIn_ = function(browserEvent) { var map = this.getMap(); map.requestRenderFrame(); // FIXME works for View2D only - map.getView().zoom(map, this.delta_, undefined, ol.control.ZOOM_DURATION); + map.getView().zoomByDelta(map, this.delta_, undefined, + ol.control.ZOOM_DURATION); }; @@ -84,5 +85,6 @@ ol.control.Zoom.prototype.handleOut_ = function(browserEvent) { var map = this.getMap(); map.requestRenderFrame(); // FIXME works for View2D only - map.getView().zoom(map, -this.delta_, undefined, ol.control.ZOOM_DURATION); + map.getView().zoomByDelta(map, -this.delta_, undefined, + ol.control.ZOOM_DURATION); }; diff --git a/src/ol/interaction/dblclickzoominteraction.js b/src/ol/interaction/dblclickzoominteraction.js index b5e3e1e589..c8f63a37c7 100644 --- a/src/ol/interaction/dblclickzoominteraction.js +++ b/src/ol/interaction/dblclickzoominteraction.js @@ -41,7 +41,7 @@ ol.interaction.DblClickZoom.prototype.handleMapBrowserEvent = // FIXME works for View2D only var view = map.getView(); goog.asserts.assert(view instanceof ol.View2D); - view.zoom(map, delta, anchor); + view.zoomByDelta(map, delta, anchor); mapBrowserEvent.preventDefault(); browserEvent.preventDefault(); } diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index 7cf2f7ffa1..cd8425b37a 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -66,7 +66,7 @@ ol.interaction.DragRotateAndZoom.prototype.handleDrag = this.lastAngle_ = theta; if (goog.isDef(this.lastMagnitude_)) { var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); - view.zoomToResolution(map, resolution); + view.zoom(map, resolution); } this.lastMagnitude_ = magnitude; }; diff --git a/src/ol/interaction/keyboardzoominteraction.js b/src/ol/interaction/keyboardzoominteraction.js index 563827ab45..cbfe06c51e 100644 --- a/src/ol/interaction/keyboardzoominteraction.js +++ b/src/ol/interaction/keyboardzoominteraction.js @@ -40,7 +40,8 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent = // FIXME works for View2D only var view = map.getView(); goog.asserts.assert(view instanceof ol.View2D); - view.zoom(map, delta, undefined, ol.interaction.KEYBOARD_ZOOM_DURATION); + view.zoomByDelta(map, delta, undefined, + ol.interaction.KEYBOARD_ZOOM_DURATION); keyEvent.preventDefault(); mapBrowserEvent.preventDefault(); } diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index b274dd7e35..125dba9713 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -111,7 +111,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) { goog.asserts.assert(view instanceof ol.View2D); map.requestRenderFrame(); - view.zoom(map, -delta, this.lastAnchor_, + view.zoomByDelta(map, -delta, this.lastAnchor_, ol.interaction.MOUSEWHEELZOOM_ANIMATION_DURATION); this.delta_ = 0; diff --git a/src/ol/interaction/touchzoominteraction.js b/src/ol/interaction/touchzoominteraction.js index 9087c5f3b4..ed14b714cf 100644 --- a/src/ol/interaction/touchzoominteraction.js +++ b/src/ol/interaction/touchzoominteraction.js @@ -59,7 +59,7 @@ ol.interaction.TouchZoom.prototype.handleTouchMove = var anchor = map.getCoordinateFromPixel(centroid); // scale, bypass the resolution constraint - view.zoom_(map, view.getResolution() * scaleDelta, anchor); + view.zoomNoConstraint(map, view.getResolution() * scaleDelta, anchor); }; @@ -73,7 +73,7 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd = var map = mapBrowserEvent.map; var view = map.getView(); // take the resolution constraint into account - view.zoomToResolution(map, view.getResolution()); + view.zoom(map, view.getResolution()); view.setHint(ol.ViewHint.INTERACTING, -1); return false; } else { diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 2fcc1f9016..0f3d3474c9 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -282,26 +282,13 @@ ol.View2D.prototype.rotate = function(map, rotation, opt_anchor) { /** - * @private * @param {ol.Map} map Map. * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. */ -ol.View2D.prototype.zoom_ = function(map, resolution, opt_anchor) { - if (goog.isDefAndNotNull(resolution) && goog.isDefAndNotNull(opt_anchor)) { - var anchor = opt_anchor; - var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); - var oldResolution = this.getResolution(); - var x = anchor.x - resolution * (anchor.x - oldCenter.x) / oldResolution; - var y = anchor.y - resolution * (anchor.y - oldCenter.y) / oldResolution; - var center = new ol.Coordinate(x, y); - map.withFrozenRendering(function() { - this.setCenter(center); - this.setResolution(resolution); - }, this); - } else { - this.setResolution(resolution); - } +ol.View2D.prototype.zoom = function(map, resolution, opt_anchor) { + resolution = this.constraints_.resolution(resolution, 0); + this.zoomNoConstraint(map, resolution, opt_anchor); }; @@ -311,7 +298,8 @@ ol.View2D.prototype.zoom_ = function(map, resolution, opt_anchor) { * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) { +ol.View2D.prototype.zoomByDelta = + function(map, delta, opt_anchor, opt_duration) { var currentResolution = this.getResolution(); var currentCenter = this.getCenter(); if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && @@ -331,7 +319,7 @@ ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) { } } var resolution = this.constraints_.resolution(currentResolution, delta); - this.zoom_(map, resolution, opt_anchor); + this.zoomNoConstraint(map, resolution, opt_anchor); }; @@ -340,9 +328,21 @@ ol.View2D.prototype.zoom = function(map, delta, opt_anchor, opt_duration) { * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. */ -ol.View2D.prototype.zoomToResolution = function(map, resolution, opt_anchor) { - resolution = this.constraints_.resolution(resolution, 0); - this.zoom_(map, resolution, opt_anchor); +ol.View2D.prototype.zoomNoConstraint = function(map, resolution, opt_anchor) { + if (goog.isDefAndNotNull(resolution) && goog.isDefAndNotNull(opt_anchor)) { + var anchor = opt_anchor; + var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); + var oldResolution = this.getResolution(); + var x = anchor.x - resolution * (anchor.x - oldCenter.x) / oldResolution; + var y = anchor.y - resolution * (anchor.y - oldCenter.y) / oldResolution; + var center = new ol.Coordinate(x, y); + map.withFrozenRendering(function() { + this.setCenter(center); + this.setResolution(resolution); + }, this); + } else { + this.setResolution(resolution); + } }; From 178c68868b350b63307557518ae17318eda56d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 18:07:45 +0100 Subject: [PATCH 06/15] Add a rotateNoConstraint View2D method --- src/ol/view2d.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 0f3d3474c9..8772f363ca 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -262,6 +262,16 @@ goog.exportProperty( */ ol.View2D.prototype.rotate = function(map, rotation, opt_anchor) { rotation = this.constraints_.rotation(rotation, 0); + this.rotateNoConstraint(map, rotation, opt_anchor); +}; + + +/** + * @param {ol.Map} map Map. + * @param {number|undefined} rotation Rotation. + * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + */ +ol.View2D.prototype.rotateNoConstraint = function(map, rotation, opt_anchor) { if (goog.isDefAndNotNull(opt_anchor)) { var anchor = opt_anchor; var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); From 7d6d82519bb327f1e74a39d4995ce28ac6928fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 18:07:56 +0100 Subject: [PATCH 07/15] Make TouchRotate interaction use rotateNoConstraint --- src/ol/interaction/touchrotateinteraction.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ol/interaction/touchrotateinteraction.js b/src/ol/interaction/touchrotateinteraction.js index 1ce5d02a77..be084f7db0 100644 --- a/src/ol/interaction/touchrotateinteraction.js +++ b/src/ol/interaction/touchrotateinteraction.js @@ -90,7 +90,7 @@ ol.interaction.TouchRotate.prototype.handleTouchMove = // rotate if (this.rotating_) { - view.rotate(map, view.getRotation() + rotationDelta, anchor); + view.rotateNoConstraint(map, view.getRotation() + rotationDelta, anchor); } }; @@ -103,6 +103,9 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd = if (this.targetTouches.length < 2) { var map = mapBrowserEvent.map; var view = map.getView(); + if (this.rotating_) { + view.rotate(map, view.getRotation()); + } view.setHint(ol.ViewHint.INTERACTING, -1); return false; } else { From 1776d80cb961956b6b2203b7b2103bb4a7e10abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 19:21:41 +0100 Subject: [PATCH 08/15] Add a snapToZero rotation constraint --- src/ol/rotationconstraint.js | 20 ++++++++++++++ src/ol/view2d.js | 2 +- test/spec/ol/rotationconstraint.test.js | 36 +++++++++++++++++++++++++ test/spec/ol/view2d.test.js | 10 +++++++ 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 test/spec/ol/rotationconstraint.test.js diff --git a/src/ol/rotationconstraint.js b/src/ol/rotationconstraint.js index 72500f9ec7..c297e13608 100644 --- a/src/ol/rotationconstraint.js +++ b/src/ol/rotationconstraint.js @@ -37,3 +37,23 @@ ol.RotationConstraint.createSnapToN = function(n) { } }; }; + + +/** + * @param {number=} opt_tolerance Tolerance. + * @return {ol.RotationConstraintType} Rotation constraint. + */ +ol.RotationConstraint.createSnapToZero = function(opt_tolerance) { + var tolerance = opt_tolerance || 0.1; + return function(rotation, delta) { + if (goog.isDef(rotation)) { + if (Math.abs(rotation + delta) <= tolerance) { + return 0; + } else { + return rotation + delta; + } + } else { + return undefined; + } + }; +}; diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 8772f363ca..77062aad97 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -387,6 +387,6 @@ ol.View2D.createConstraints_ = function(view2DOptions) { zoomFactor, maxResolution, numZoomLevels - 1); } // FIXME rotation constraint is not configurable at the moment - var rotationConstraint = ol.RotationConstraint.none; + var rotationConstraint = ol.RotationConstraint.createSnapToZero(); return new ol.Constraints(resolutionConstraint, rotationConstraint); }; diff --git a/test/spec/ol/rotationconstraint.test.js b/test/spec/ol/rotationconstraint.test.js new file mode 100644 index 0000000000..950a8892e4 --- /dev/null +++ b/test/spec/ol/rotationconstraint.test.js @@ -0,0 +1,36 @@ +goog.provide('ol.test.RotationConstraint'); + +describe('ol.RotationConstraint', function() { + + describe('SnapToZero', function() { + + it('returns expected rotation value', function() { + var rotationConstraint = ol.RotationConstraint.createSnapToZero(0.3); + + expect(rotationConstraint(0.1, 0)).toEqual(0); + expect(rotationConstraint(0.2, 0)).toEqual(0); + expect(rotationConstraint(0.3, 0)).toEqual(0); + expect(rotationConstraint(0.4, 0)).toEqual(0.4); + + expect(rotationConstraint(-0.1, 0)).toEqual(0); + expect(rotationConstraint(-0.2, 0)).toEqual(0); + expect(rotationConstraint(-0.3, 0)).toEqual(0); + expect(rotationConstraint(-0.4, 0)).toEqual(-0.4); + + expect(rotationConstraint(1, -0.9)).toEqual(0); + expect(rotationConstraint(1, -0.8)).toEqual(0); + // floating-point arithmetic + expect(rotationConstraint(1, -0.7)).not.toEqual(0); + expect(rotationConstraint(1, -0.6)).toEqual(0.4); + + expect(rotationConstraint(-1, 0.9)).toEqual(0); + expect(rotationConstraint(-1, 0.8)).toEqual(0); + // floating-point arithmetic + expect(rotationConstraint(-1, 0.7)).not.toEqual(0); + expect(rotationConstraint(-1, 0.6)).toEqual(-0.4); + }); + + }); +}); + +goog.require('ol.RotationConstraint'); diff --git a/test/spec/ol/view2d.test.js b/test/spec/ol/view2d.test.js index d78e17dad4..efed46163b 100644 --- a/test/spec/ol/view2d.test.js +++ b/test/spec/ol/view2d.test.js @@ -49,6 +49,16 @@ describe('ol.View2D', function() { }); }); + + describe('create rotation constraint', function() { + it('gives a correct rotation constraint function', function() { + var options = {}; + var fn = ol.View2D.createConstraints_(options).rotation; + expect(fn(0.01, 0)).toEqual(0); + expect(fn(0.15, 0)).toEqual(0.15); + }); + }); + }); }); From 2f611529dd04928f7faf256177174b7a88128271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:04:51 +0100 Subject: [PATCH 09/15] Do not apply rotation constraint while rotating This is on par to what the TouchRotate interaction does. --- src/ol/interaction/dragrotateinteraction.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index 276fb15c56..90b92c0be5 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -1,6 +1,7 @@ goog.provide('ol.interaction.DragRotate'); goog.require('ol.View2D'); +goog.require('ol.ViewHint'); goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.Drag'); @@ -46,12 +47,26 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) { // FIXME supports View2D only goog.asserts.assert(view instanceof ol.View2D); map.requestRenderFrame(); - view.rotate(map, view.getRotation() - delta); + view.rotateNoConstraint(map, view.getRotation() - delta); } this.lastAngle_ = theta; }; +/** + * @inheritDoc + */ +ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) { + var browserEvent = mapBrowserEvent.browserEvent; + var map = mapBrowserEvent.map; + // FIXME supports View2D only + var view = map.getView(); + goog.asserts.assert(view instanceof ol.View2D); + view.rotate(map, view.getRotation()); + view.setHint(ol.ViewHint.INTERACTING, -1); +}; + + /** * @inheritDoc */ @@ -65,6 +80,7 @@ ol.interaction.DragRotate.prototype.handleDragStart = goog.asserts.assert(view instanceof ol.View2D); map.requestRenderFrame(); this.lastAngle_ = undefined; + view.setHint(ol.ViewHint.INTERACTING, 1); return true; } else { return false; From c431acacca0dbd01e413730d82548dfcf68cfdee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:29:18 +0100 Subject: [PATCH 10/15] Make animating rotation possible --- src/ol/view2d.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 77062aad97..4662678d3b 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -259,8 +259,28 @@ goog.exportProperty( * @param {ol.Map} map Map. * @param {number|undefined} rotation Rotation. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.rotate = function(map, rotation, opt_anchor) { +ol.View2D.prototype.rotate = + function(map, rotation, opt_anchor, opt_duration) { + var currentRotation = this.getRotation(); + var currentCenter = this.getCenter(); + if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && + goog.isDef(opt_duration)) { + map.requestRenderFrame(); + map.addPreRenderFunction(ol.animation.rotate({ + rotation: currentRotation, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + if (goog.isDef(opt_anchor)) { + map.addPreRenderFunction(ol.animation.pan({ + source: currentCenter, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + } + } rotation = this.constraints_.rotation(rotation, 0); this.rotateNoConstraint(map, rotation, opt_anchor); }; From d42d88c198d24f5569a6ea67f2d35c587b1416c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:30:15 +0100 Subject: [PATCH 11/15] Animate rotation when releasing mouse or fingers --- src/ol/interaction/dragrotateinteraction.js | 9 ++++++++- src/ol/interaction/touchrotateinteraction.js | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index 90b92c0be5..d4036be9c1 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -6,6 +6,12 @@ goog.require('ol.interaction.ConditionType'); goog.require('ol.interaction.Drag'); +/** + * @define {number} Animation duration. + */ +ol.interaction.DRAGROTATE_ANIMATION_DURATION = 250; + + /** * @constructor @@ -62,7 +68,8 @@ ol.interaction.DragRotate.prototype.handleDragEnd = function(mapBrowserEvent) { // FIXME supports View2D only var view = map.getView(); goog.asserts.assert(view instanceof ol.View2D); - view.rotate(map, view.getRotation()); + view.rotate(map, view.getRotation(), undefined, + ol.interaction.DRAGROTATE_ANIMATION_DURATION); view.setHint(ol.ViewHint.INTERACTING, -1); }; diff --git a/src/ol/interaction/touchrotateinteraction.js b/src/ol/interaction/touchrotateinteraction.js index be084f7db0..a3a6e14dfe 100644 --- a/src/ol/interaction/touchrotateinteraction.js +++ b/src/ol/interaction/touchrotateinteraction.js @@ -8,6 +8,14 @@ goog.require('ol.ViewHint'); goog.require('ol.interaction.Touch'); +/** + * @define {number} Animation duration. + */ +ol.interaction.TOUCHROTATE_ANIMATION_DURATION = 250; + + + +/** /** * @constructor @@ -104,7 +112,8 @@ ol.interaction.TouchRotate.prototype.handleTouchEnd = var map = mapBrowserEvent.map; var view = map.getView(); if (this.rotating_) { - view.rotate(map, view.getRotation()); + view.rotate(map, view.getRotation(), undefined, + ol.interaction.TOUCHROTATE_ANIMATION_DURATION); } view.setHint(ol.ViewHint.INTERACTING, -1); return false; From 43b1e11e7af96231b61bbdac17118f0b1ed27d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:51:45 +0100 Subject: [PATCH 12/15] 2DView refactoring This refactoring makes animating zoom, as opposed to zoomByDelta, possible. --- src/ol/view2d.js | 145 +++++++++++++++++++++++++---------------------- 1 file changed, 78 insertions(+), 67 deletions(-) diff --git a/src/ol/view2d.js b/src/ol/view2d.js index 4662678d3b..f022a1bf25 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -263,26 +263,8 @@ goog.exportProperty( */ ol.View2D.prototype.rotate = function(map, rotation, opt_anchor, opt_duration) { - var currentRotation = this.getRotation(); - var currentCenter = this.getCenter(); - if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && - goog.isDef(opt_duration)) { - map.requestRenderFrame(); - map.addPreRenderFunction(ol.animation.rotate({ - rotation: currentRotation, - duration: opt_duration, - easing: goog.fx.easing.easeOut - })); - if (goog.isDef(opt_anchor)) { - map.addPreRenderFunction(ol.animation.pan({ - source: currentCenter, - duration: opt_duration, - easing: goog.fx.easing.easeOut - })); - } - } rotation = this.constraints_.rotation(rotation, 0); - this.rotateNoConstraint(map, rotation, opt_anchor); + this.rotateNoConstraint(map, rotation, opt_anchor, opt_duration); }; @@ -290,23 +272,45 @@ ol.View2D.prototype.rotate = * @param {ol.Map} map Map. * @param {number|undefined} rotation Rotation. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.rotateNoConstraint = function(map, rotation, opt_anchor) { - if (goog.isDefAndNotNull(opt_anchor)) { - var anchor = opt_anchor; - var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); - var center = new ol.Coordinate( - oldCenter.x - anchor.x, - oldCenter.y - anchor.y); - center.rotate(rotation - this.getRotation()); - center.x += anchor.x; - center.y += anchor.y; - map.withFrozenRendering(function() { - this.setCenter(center); +ol.View2D.prototype.rotateNoConstraint = + function(map, rotation, opt_anchor, opt_duration) { + if (goog.isDefAndNotNull(rotation)) { + var currentRotation = this.getRotation(); + var currentCenter = this.getCenter(); + if (goog.isDef(currentRotation) && goog.isDef(currentCenter) && + goog.isDef(opt_duration)) { + map.requestRenderFrame(); + map.addPreRenderFunction(ol.animation.rotate({ + rotation: currentRotation, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + if (goog.isDef(opt_anchor)) { + map.addPreRenderFunction(ol.animation.pan({ + source: currentCenter, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + } + } + if (goog.isDefAndNotNull(opt_anchor)) { + var anchor = opt_anchor; + var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); + var center = new ol.Coordinate( + oldCenter.x - anchor.x, + oldCenter.y - anchor.y); + center.rotate(rotation - this.getRotation()); + center.x += anchor.x; + center.y += anchor.y; + map.withFrozenRendering(function() { + this.setCenter(center); + this.setRotation(rotation); + }, this); + } else { this.setRotation(rotation); - }, this); - } else { - this.setRotation(rotation); + } } }; @@ -315,10 +319,12 @@ ol.View2D.prototype.rotateNoConstraint = function(map, rotation, opt_anchor) { * @param {ol.Map} map Map. * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.zoom = function(map, resolution, opt_anchor) { +ol.View2D.prototype.zoom = + function(map, resolution, opt_anchor, opt_duration) { resolution = this.constraints_.resolution(resolution, 0); - this.zoomNoConstraint(map, resolution, opt_anchor); + this.zoomNoConstraint(map, resolution, opt_anchor, opt_duration); }; @@ -331,25 +337,8 @@ ol.View2D.prototype.zoom = function(map, resolution, opt_anchor) { ol.View2D.prototype.zoomByDelta = function(map, delta, opt_anchor, opt_duration) { var currentResolution = this.getResolution(); - var currentCenter = this.getCenter(); - if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && - goog.isDef(opt_duration)) { - map.requestRenderFrame(); - map.addPreRenderFunction(ol.animation.zoom({ - resolution: currentResolution, - duration: opt_duration, - easing: goog.fx.easing.easeOut - })); - if (goog.isDef(opt_anchor)) { - map.addPreRenderFunction(ol.animation.pan({ - source: currentCenter, - duration: opt_duration, - easing: goog.fx.easing.easeOut - })); - } - } var resolution = this.constraints_.resolution(currentResolution, delta); - this.zoomNoConstraint(map, resolution, opt_anchor); + this.zoomNoConstraint(map, resolution, opt_anchor, opt_duration); }; @@ -357,21 +346,43 @@ ol.View2D.prototype.zoomByDelta = * @param {ol.Map} map Map. * @param {number|undefined} resolution Resolution to go to. * @param {ol.Coordinate=} opt_anchor Anchor coordinate. + * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.zoomNoConstraint = function(map, resolution, opt_anchor) { - if (goog.isDefAndNotNull(resolution) && goog.isDefAndNotNull(opt_anchor)) { - var anchor = opt_anchor; - var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); - var oldResolution = this.getResolution(); - var x = anchor.x - resolution * (anchor.x - oldCenter.x) / oldResolution; - var y = anchor.y - resolution * (anchor.y - oldCenter.y) / oldResolution; - var center = new ol.Coordinate(x, y); - map.withFrozenRendering(function() { - this.setCenter(center); +ol.View2D.prototype.zoomNoConstraint = + function(map, resolution, opt_anchor, opt_duration) { + if (goog.isDefAndNotNull(resolution)) { + var currentResolution = this.getResolution(); + var currentCenter = this.getCenter(); + if (goog.isDef(currentResolution) && goog.isDef(currentCenter) && + goog.isDef(opt_duration)) { + map.requestRenderFrame(); + map.addPreRenderFunction(ol.animation.zoom({ + resolution: currentResolution, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + if (goog.isDef(opt_anchor)) { + map.addPreRenderFunction(ol.animation.pan({ + source: currentCenter, + duration: opt_duration, + easing: goog.fx.easing.easeOut + })); + } + } + if (goog.isDefAndNotNull(opt_anchor)) { + var anchor = opt_anchor; + var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter()); + var oldResolution = this.getResolution(); + var x = anchor.x - resolution * (anchor.x - oldCenter.x) / oldResolution; + var y = anchor.y - resolution * (anchor.y - oldCenter.y) / oldResolution; + var center = new ol.Coordinate(x, y); + map.withFrozenRendering(function() { + this.setCenter(center); + this.setResolution(resolution); + }, this); + } else { this.setResolution(resolution); - }, this); - } else { - this.setResolution(resolution); + } } }; From e598e4b9b246fed403424548b0d07da8d3b899f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Mon, 4 Mar 2013 20:59:33 +0100 Subject: [PATCH 13/15] Animate zoom after pinch --- src/ol/interaction/touchzoominteraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ol/interaction/touchzoominteraction.js b/src/ol/interaction/touchzoominteraction.js index ed14b714cf..76d99bafd7 100644 --- a/src/ol/interaction/touchzoominteraction.js +++ b/src/ol/interaction/touchzoominteraction.js @@ -8,6 +8,12 @@ goog.require('ol.ViewHint'); goog.require('ol.interaction.Touch'); +/** + * @define {number} Animation duration. + */ +ol.interaction.TOUCHZOOM_ANIMATION_DURATION = 250; + + /** * @constructor @@ -73,7 +79,8 @@ ol.interaction.TouchZoom.prototype.handleTouchEnd = var map = mapBrowserEvent.map; var view = map.getView(); // take the resolution constraint into account - view.zoom(map, view.getResolution()); + view.zoom(map, view.getResolution(), undefined, + ol.interaction.TOUCHZOOM_ANIMATION_DURATION); view.setHint(ol.ViewHint.INTERACTING, -1); return false; } else { From 29e610b9f3b57455fa4f44eb83a71c791c878ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 5 Mar 2013 10:07:33 +0100 Subject: [PATCH 14/15] Animate double click/tap zoom --- src/ol/interaction/dblclickzoominteraction.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ol/interaction/dblclickzoominteraction.js b/src/ol/interaction/dblclickzoominteraction.js index c8f63a37c7..e758e67d44 100644 --- a/src/ol/interaction/dblclickzoominteraction.js +++ b/src/ol/interaction/dblclickzoominteraction.js @@ -8,6 +8,12 @@ goog.require('ol.View2D'); goog.require('ol.interaction.Interaction'); +/** + * @define {number} Animation duration. + */ +ol.interaction.DBLCLICKZOOM_ANIMATION_DURATION = 250; + + /** * @constructor @@ -41,7 +47,8 @@ ol.interaction.DblClickZoom.prototype.handleMapBrowserEvent = // FIXME works for View2D only var view = map.getView(); goog.asserts.assert(view instanceof ol.View2D); - view.zoomByDelta(map, delta, anchor); + view.zoomByDelta(map, delta, anchor, + ol.interaction.DBLCLICKZOOM_ANIMATION_DURATION); mapBrowserEvent.preventDefault(); browserEvent.preventDefault(); } From b884f2f25d6b8dd4ddb065a1574286bc13efd5da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 5 Mar 2013 12:51:03 +0100 Subject: [PATCH 15/15] View2D NoConstraint methods renamed --- src/ol/interaction/dragrotateinteraction.js | 2 +- src/ol/interaction/touchrotateinteraction.js | 3 ++- src/ol/interaction/touchzoominteraction.js | 2 +- src/ol/view2d.js | 10 +++++----- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ol/interaction/dragrotateinteraction.js b/src/ol/interaction/dragrotateinteraction.js index d4036be9c1..2ad45dfa78 100644 --- a/src/ol/interaction/dragrotateinteraction.js +++ b/src/ol/interaction/dragrotateinteraction.js @@ -53,7 +53,7 @@ ol.interaction.DragRotate.prototype.handleDrag = function(mapBrowserEvent) { // FIXME supports View2D only goog.asserts.assert(view instanceof ol.View2D); map.requestRenderFrame(); - view.rotateNoConstraint(map, view.getRotation() - delta); + view.rotateWithoutConstraints(map, view.getRotation() - delta); } this.lastAngle_ = theta; }; diff --git a/src/ol/interaction/touchrotateinteraction.js b/src/ol/interaction/touchrotateinteraction.js index a3a6e14dfe..3f4abc3ce7 100644 --- a/src/ol/interaction/touchrotateinteraction.js +++ b/src/ol/interaction/touchrotateinteraction.js @@ -98,7 +98,8 @@ ol.interaction.TouchRotate.prototype.handleTouchMove = // rotate if (this.rotating_) { - view.rotateNoConstraint(map, view.getRotation() + rotationDelta, anchor); + view.rotateWithoutConstraints(map, view.getRotation() + rotationDelta, + anchor); } }; diff --git a/src/ol/interaction/touchzoominteraction.js b/src/ol/interaction/touchzoominteraction.js index 76d99bafd7..bbb0bab518 100644 --- a/src/ol/interaction/touchzoominteraction.js +++ b/src/ol/interaction/touchzoominteraction.js @@ -65,7 +65,7 @@ ol.interaction.TouchZoom.prototype.handleTouchMove = var anchor = map.getCoordinateFromPixel(centroid); // scale, bypass the resolution constraint - view.zoomNoConstraint(map, view.getResolution() * scaleDelta, anchor); + view.zoomWithoutConstraints(map, view.getResolution() * scaleDelta, anchor); }; diff --git a/src/ol/view2d.js b/src/ol/view2d.js index f022a1bf25..f472014250 100644 --- a/src/ol/view2d.js +++ b/src/ol/view2d.js @@ -264,7 +264,7 @@ goog.exportProperty( ol.View2D.prototype.rotate = function(map, rotation, opt_anchor, opt_duration) { rotation = this.constraints_.rotation(rotation, 0); - this.rotateNoConstraint(map, rotation, opt_anchor, opt_duration); + this.rotateWithoutConstraints(map, rotation, opt_anchor, opt_duration); }; @@ -274,7 +274,7 @@ ol.View2D.prototype.rotate = * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.rotateNoConstraint = +ol.View2D.prototype.rotateWithoutConstraints = function(map, rotation, opt_anchor, opt_duration) { if (goog.isDefAndNotNull(rotation)) { var currentRotation = this.getRotation(); @@ -324,7 +324,7 @@ ol.View2D.prototype.rotateNoConstraint = ol.View2D.prototype.zoom = function(map, resolution, opt_anchor, opt_duration) { resolution = this.constraints_.resolution(resolution, 0); - this.zoomNoConstraint(map, resolution, opt_anchor, opt_duration); + this.zoomWithoutConstraints(map, resolution, opt_anchor, opt_duration); }; @@ -338,7 +338,7 @@ ol.View2D.prototype.zoomByDelta = function(map, delta, opt_anchor, opt_duration) { var currentResolution = this.getResolution(); var resolution = this.constraints_.resolution(currentResolution, delta); - this.zoomNoConstraint(map, resolution, opt_anchor, opt_duration); + this.zoomWithoutConstraints(map, resolution, opt_anchor, opt_duration); }; @@ -348,7 +348,7 @@ ol.View2D.prototype.zoomByDelta = * @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {number=} opt_duration Duration. */ -ol.View2D.prototype.zoomNoConstraint = +ol.View2D.prototype.zoomWithoutConstraints = function(map, resolution, opt_anchor, opt_duration) { if (goog.isDefAndNotNull(resolution)) { var currentResolution = this.getResolution();