diff --git a/src/ol/interaction/centerconstraint.js b/src/ol/centerconstraint.js similarity index 100% rename from src/ol/interaction/centerconstraint.js rename to src/ol/centerconstraint.js diff --git a/src/ol/constraints.js b/src/ol/constraints.js new file mode 100644 index 0000000000..81b3e4cd57 --- /dev/null +++ b/src/ol/constraints.js @@ -0,0 +1,27 @@ +goog.provide('ol.Constraints'); + +goog.require('ol.ResolutionConstraintType'); +goog.require('ol.RotationConstraintType'); + + + +/** + * @constructor + * @param {ol.ResolutionConstraintType} resolutionConstraint + * Resolution constraint. + * @param {ol.RotationConstraintType} rotationConstraint + * Rotation constraint. + */ +ol.Constraints = function(resolutionConstraint, rotationConstraint) { + + /** + * @type {ol.ResolutionConstraintType} + */ + this.resolution = resolutionConstraint; + + /** + * @type {ol.RotationConstraintType} + */ + this.rotation = rotationConstraint; + +}; diff --git a/src/ol/control/zoom.js b/src/ol/control/zoom.js index e9c12956b0..716150a044 100644 --- a/src/ol/control/zoom.js +++ b/src/ol/control/zoom.js @@ -5,6 +5,7 @@ goog.require('goog.dom.TagName'); goog.require('goog.events'); goog.require('goog.events.EventType'); goog.require('ol.Projection'); +goog.require('ol.ResolutionConstraint'); goog.require('ol.control.Control'); @@ -30,9 +31,8 @@ ol.control.Zoom = function(map, opt_resolutions) { * @type {Function} * @private */ - this.constraint_ = - ol.interaction.ResolutionConstraint.createSnapToResolutions( - opt_resolutions); + this.constraint_ = ol.ResolutionConstraint.createSnapToResolutions( + opt_resolutions); /** * @type {Element} diff --git a/src/ol/interaction/constraints.js b/src/ol/interaction/constraints.js deleted file mode 100644 index e4062fee72..0000000000 --- a/src/ol/interaction/constraints.js +++ /dev/null @@ -1,29 +0,0 @@ -goog.provide('ol.interaction.Constraints'); - -goog.require('ol.interaction.CenterConstraintType'); -goog.require('ol.interaction.ResolutionConstraintType'); -goog.require('ol.interaction.RotationConstraintType'); - - - -/** - * @constructor - * @param {ol.interaction.ResolutionConstraintType} resolutionConstraint - * Resolution constraint. - * @param {ol.interaction.RotationConstraintType} rotationConstraint - * Rotation constraint. - */ -ol.interaction.Constraints = - function(resolutionConstraint, rotationConstraint) { - - /** - * @type {ol.interaction.ResolutionConstraintType} - */ - this.resolution = resolutionConstraint; - - /** - * @type {ol.interaction.RotationConstraintType} - */ - this.rotation = rotationConstraint; - -}; diff --git a/src/ol/map.js b/src/ol/map.js index 47625465e0..d5c3671f47 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -26,6 +26,7 @@ goog.require('goog.fx.anim.Animated'); goog.require('goog.object'); goog.require('ol.Collection'); goog.require('ol.Color'); +goog.require('ol.Constraints'); goog.require('ol.Coordinate'); goog.require('ol.Extent'); goog.require('ol.MapBrowserEvent'); @@ -34,7 +35,6 @@ goog.require('ol.Pixel'); goog.require('ol.Projection'); goog.require('ol.Size'); goog.require('ol.TransformFunction'); -goog.require('ol.interaction.Constraints'); goog.require('ol.interaction.Interaction'); goog.require('ol.renderer.Layer'); @@ -139,8 +139,7 @@ ol.Map = function(container, mapOptionsLiteral, opt_viewportSizeMonitor) { /** * @private - * FIXME change ol.interaction.Constraints -> ol.Constraints - * @type {ol.interaction.Constraints} + * @type {ol.Constraints} */ this.constraints_ = mapOptions.constraints; diff --git a/src/ol/mapoptions.js b/src/ol/mapoptions.js index 0dde575a2d..ac3b3313f0 100644 --- a/src/ol/mapoptions.js +++ b/src/ol/mapoptions.js @@ -4,17 +4,17 @@ goog.provide('ol.MapOptionsType'); goog.provide('ol.RendererHint'); goog.require('ol.Collection'); +goog.require('ol.Constraints'); goog.require('ol.Projection'); +goog.require('ol.ResolutionConstraint'); +goog.require('ol.RotationConstraint'); goog.require('ol.interaction.AltDragRotate'); goog.require('ol.interaction.CenterConstraint'); -goog.require('ol.interaction.Constraints'); goog.require('ol.interaction.DblClickZoom'); goog.require('ol.interaction.DragPan'); goog.require('ol.interaction.KeyboardPan'); goog.require('ol.interaction.KeyboardZoom'); goog.require('ol.interaction.MouseWheelZoom'); -goog.require('ol.interaction.ResolutionConstraint'); -goog.require('ol.interaction.RotationConstraint'); goog.require('ol.interaction.ShiftDragZoom'); goog.require('ol.renderer.Map'); goog.require('ol.renderer.dom'); @@ -152,7 +152,7 @@ ol.MapOptions.create = function(mapOptionsLiteral) { } /** - * @type {ol.interaction.Constraints} + * @type {ol.Constraints} */ var constraints = ol.MapOptions.createConstraints_(mapOptionsLiteral); @@ -168,16 +168,14 @@ ol.MapOptions.create = function(mapOptionsLiteral) { /** * @private * @param {ol.MapOptionsLiteral} mapOptionsLiteral Map options literal. - * @return {ol.interaction.Constraints} Map constraints. + * @return {ol.Constraints} Map constraints. */ ol.MapOptions.createConstraints_ = function(mapOptionsLiteral) { // FIXME this should be configurable - var resolutionConstraint = - ol.interaction.ResolutionConstraint.createSnapToPower( - Math.exp(Math.log(2) / 4), ol.Projection.EPSG_3857_HALF_SIZE / 128); - var rotationConstraint = ol.interaction.RotationConstraint.none; - return new ol.interaction.Constraints( - resolutionConstraint, rotationConstraint); + var resolutionConstraint = ol.ResolutionConstraint.createSnapToPower( + Math.exp(Math.log(2) / 4), ol.Projection.EPSG_3857_HALF_SIZE / 128); + var rotationConstraint = ol.RotationConstraint.none; + return new ol.Constraints(resolutionConstraint, rotationConstraint); }; diff --git a/src/ol/interaction/resolutionconstraint.js b/src/ol/resolutionconstraint.js similarity index 75% rename from src/ol/interaction/resolutionconstraint.js rename to src/ol/resolutionconstraint.js index 79eb7b800c..5aa47625be 100644 --- a/src/ol/interaction/resolutionconstraint.js +++ b/src/ol/resolutionconstraint.js @@ -1,5 +1,5 @@ -goog.provide('ol.interaction.ResolutionConstraint'); -goog.provide('ol.interaction.ResolutionConstraintType'); +goog.provide('ol.ResolutionConstraint'); +goog.provide('ol.ResolutionConstraintType'); goog.require('goog.math'); goog.require('ol.array'); @@ -8,16 +8,16 @@ goog.require('ol.array'); /** * @typedef {function((number|undefined), number): (number|undefined)} */ -ol.interaction.ResolutionConstraintType; +ol.ResolutionConstraintType; /** * @param {number} power Power. * @param {number} maxResolution Maximum resolution. * @param {number=} opt_minResolution Minimum resolution. - * @return {ol.interaction.ResolutionConstraintType} Zoom function. + * @return {ol.ResolutionConstraintType} Zoom function. */ -ol.interaction.ResolutionConstraint.createContinuous = +ol.ResolutionConstraint.createContinuous = function(power, maxResolution, opt_minResolution) { var minResolution = opt_minResolution || 0; return function(resolution, delta) { @@ -33,9 +33,9 @@ ol.interaction.ResolutionConstraint.createContinuous = /** * @param {Array.} resolutions Resolutions. - * @return {ol.interaction.ResolutionConstraintType} Zoom function. + * @return {ol.ResolutionConstraintType} Zoom function. */ -ol.interaction.ResolutionConstraint.createSnapToResolutions = +ol.ResolutionConstraint.createSnapToResolutions = function(resolutions) { return function(resolution, delta) { if (goog.isDef(resolution)) { @@ -53,9 +53,9 @@ ol.interaction.ResolutionConstraint.createSnapToResolutions = * @param {number} power Power. * @param {number} maxResolution Maximum resolution. * @param {number=} opt_maxLevel Maximum level. - * @return {ol.interaction.ResolutionConstraintType} Zoom function. + * @return {ol.ResolutionConstraintType} Zoom function. */ -ol.interaction.ResolutionConstraint.createSnapToPower = +ol.ResolutionConstraint.createSnapToPower = function(power, maxResolution, opt_maxLevel) { return function(resolution, delta) { if (goog.isDef(resolution)) { diff --git a/src/ol/interaction/rotationconstraint.js b/src/ol/rotationconstraint.js similarity index 62% rename from src/ol/interaction/rotationconstraint.js rename to src/ol/rotationconstraint.js index a978999a2d..72500f9ec7 100644 --- a/src/ol/interaction/rotationconstraint.js +++ b/src/ol/rotationconstraint.js @@ -1,11 +1,11 @@ -goog.provide('ol.interaction.RotationConstraint'); -goog.provide('ol.interaction.RotationConstraintType'); +goog.provide('ol.RotationConstraint'); +goog.provide('ol.RotationConstraintType'); /** * @typedef {function((number|undefined), number): (number|undefined)} */ -ol.interaction.RotationConstraintType; +ol.RotationConstraintType; /** @@ -13,7 +13,7 @@ ol.interaction.RotationConstraintType; * @param {number} delta Delta. * @return {number|undefined} Rotation. */ -ol.interaction.RotationConstraint.none = function(rotation, delta) { +ol.RotationConstraint.none = function(rotation, delta) { if (goog.isDef(rotation)) { return rotation + delta; } else { @@ -24,9 +24,9 @@ ol.interaction.RotationConstraint.none = function(rotation, delta) { /** * @param {number} n N. - * @return {ol.interaction.RotationConstraintType} Rotation constraint. + * @return {ol.RotationConstraintType} Rotation constraint. */ -ol.interaction.RotationConstraint.createSnapToN = function(n) { +ol.RotationConstraint.createSnapToN = function(n) { var theta = 2 * Math.PI / n; return function(rotation, delta) { if (goog.isDef(rotation)) { diff --git a/test/ol.html b/test/ol.html index cfefe700bd..90f2f0f9b8 100644 --- a/test/ol.html +++ b/test/ol.html @@ -80,7 +80,7 @@ - +