Constraint objects moved to ol namespace from ol.interaction namespace
This commit is contained in:
27
src/ol/constraints.js
Normal file
27
src/ol/constraints.js
Normal file
@@ -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;
|
||||
|
||||
};
|
||||
@@ -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}
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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.<number>} 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)) {
|
||||
@@ -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)) {
|
||||
Reference in New Issue
Block a user