Add ol.CenterConstraint
This commit is contained in:
committed by
Frederic Junod
parent
2878309a41
commit
1c003b5ab1
42
src/ol/centerconstraint.js
Normal file
42
src/ol/centerconstraint.js
Normal file
@@ -0,0 +1,42 @@
|
||||
goog.provide('ol.CenterConstraint');
|
||||
goog.provide('ol.CenterConstraintType');
|
||||
|
||||
goog.require('goog.math');
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {function((ol.Coordinate|undefined)): (ol.Coordinate|undefined)}
|
||||
*/
|
||||
ol.CenterConstraintType;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Extent} extent Extent.
|
||||
* @return {ol.CenterConstraintType}
|
||||
*/
|
||||
ol.CenterConstraint.createExtent = function(extent) {
|
||||
return (
|
||||
/**
|
||||
* @param {ol.Coordinate|undefined} center Center.
|
||||
* @return {ol.Coordinate|undefined} Center.
|
||||
*/
|
||||
function(center) {
|
||||
if (goog.isDef(center)) {
|
||||
return [
|
||||
goog.math.clamp(center[0], extent[0], extent[2]),
|
||||
goog.math.clamp(center[1], extent[1], extent[3])
|
||||
];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Coordinate|undefined} center Center.
|
||||
* @return {ol.Coordinate|undefined} Center.
|
||||
*/
|
||||
ol.CenterConstraint.none = function(center) {
|
||||
return center;
|
||||
};
|
||||
Reference in New Issue
Block a user