Rename ol.View2D to ol.View

This commit is contained in:
Tim Schaub
2014-06-26 16:51:26 -04:00
parent b9f444a008
commit 47d37fabea
98 changed files with 302 additions and 302 deletions

View File

@@ -74,15 +74,15 @@ ol.interaction.DragPan.prototype.handlePointerDrag = function(mapBrowserEvent) {
var deltaX = this.lastCentroid[0] - centroid[0];
var deltaY = centroid[1] - this.lastCentroid[1];
var map = mapBrowserEvent.map;
var view2D = map.getView();
var viewState = view2D.getState();
var view = map.getView();
var viewState = view.getState();
var center = [deltaX, deltaY];
ol.coordinate.scale(center, viewState.resolution);
ol.coordinate.rotate(center, viewState.rotation);
ol.coordinate.add(center, viewState.center);
center = view2D.constrainCenter(center);
center = view.constrainCenter(center);
map.render();
view2D.setCenter(center);
view.setCenter(center);
}
this.lastCentroid = centroid;
};
@@ -94,12 +94,12 @@ ol.interaction.DragPan.prototype.handlePointerDrag = function(mapBrowserEvent) {
ol.interaction.DragPan.prototype.handlePointerUp =
function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view2D = map.getView();
var view = map.getView();
if (this.targetPointers.length === 0) {
if (!this.noKinetic_ && this.kinetic_ && this.kinetic_.end()) {
var distance = this.kinetic_.getDistance();
var angle = this.kinetic_.getAngle();
var center = view2D.getCenter();
var center = view.getCenter();
goog.asserts.assert(goog.isDef(center));
this.kineticPreRenderFn_ = this.kinetic_.pan(center);
map.beforeRender(this.kineticPreRenderFn_);
@@ -108,10 +108,10 @@ ol.interaction.DragPan.prototype.handlePointerUp =
centerpx[0] - distance * Math.cos(angle),
centerpx[1] - distance * Math.sin(angle)
]);
dest = view2D.constrainCenter(dest);
view2D.setCenter(dest);
dest = view.constrainCenter(dest);
view.setCenter(dest);
}
view2D.setHint(ol.ViewHint.INTERACTING, -1);
view.setHint(ol.ViewHint.INTERACTING, -1);
map.render();
return false;
} else {
@@ -128,15 +128,15 @@ ol.interaction.DragPan.prototype.handlePointerDown =
function(mapBrowserEvent) {
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
var map = mapBrowserEvent.map;
var view2D = map.getView();
var view = map.getView();
this.lastCentroid = null;
if (!this.handlingDownUpSequence) {
view2D.setHint(ol.ViewHint.INTERACTING, 1);
view.setHint(ol.ViewHint.INTERACTING, 1);
}
map.render();
if (!goog.isNull(this.kineticPreRenderFn_) &&
map.removePreRenderFunction(this.kineticPreRenderFn_)) {
view2D.setCenter(mapBrowserEvent.frameState.viewState.center);
view.setCenter(mapBrowserEvent.frameState.viewState.center);
this.kineticPreRenderFn_ = null;
}
if (this.kinetic_) {

View File

@@ -68,7 +68,7 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration.
*/
@@ -92,7 +92,7 @@ ol.interaction.Interaction.pan = function(
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
@@ -107,7 +107,7 @@ ol.interaction.Interaction.rotate =
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
@@ -139,7 +139,7 @@ ol.interaction.Interaction.rotateWithoutConstraints =
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
@@ -162,7 +162,7 @@ ol.interaction.Interaction.zoom =
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {number} delta Delta from previous zoom level.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.
@@ -178,7 +178,7 @@ ol.interaction.Interaction.zoomByDelta =
/**
* @param {ol.Map} map Map.
* @param {ol.View2D} view View.
* @param {ol.View} view View.
* @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration.

View File

@@ -45,7 +45,7 @@ goog.require('ol.RendererType');
goog.require('ol.Size');
goog.require('ol.Tile');
goog.require('ol.TileQueue');
goog.require('ol.View2D');
goog.require('ol.View');
goog.require('ol.ViewHint');
goog.require('ol.control');
goog.require('ol.extent');
@@ -125,7 +125,7 @@ ol.MapProperty = {
* needs a view, one or more layers, and a target container:
*
* var map = new ol.Map({
* view: new ol.View2D({
* view: new ol.View({
* center: [0, 0],
* zoom: 1
* }),
@@ -748,12 +748,12 @@ goog.exportProperty(
/**
* Get the view associated with this map. A view manages properties such as
* center and resolution.
* @return {ol.View2D|undefined} The view that controls this map.
* @return {ol.View|undefined} The view that controls this map.
* @todo observable
* @todo api stable
*/
ol.Map.prototype.getView = function() {
return /** @type {ol.View2D} */ (this.get(ol.MapProperty.VIEW));
return /** @type {ol.View} */ (this.get(ol.MapProperty.VIEW));
};
goog.exportProperty(
ol.Map.prototype,
@@ -1315,7 +1315,7 @@ goog.exportProperty(
/**
* Set the view for this map.
* @param {ol.View2D} view The view that controls this map.
* @param {ol.View} view The view that controls this map.
* @todo observable
* @todo api stable
*/
@@ -1417,7 +1417,7 @@ ol.Map.createOptionsInternal = function(options) {
values[ol.MapProperty.TARGET] = options.target;
values[ol.MapProperty.VIEW] = goog.isDef(options.view) ?
options.view : new ol.View2D();
options.view : new ol.View();
/**
* @type {function(new: ol.renderer.Map, Element, ol.Map)}

View File

@@ -1,4 +1,4 @@
goog.provide('ol.View2D');
goog.provide('ol.View');
goog.provide('ol.View2DProperty');
goog.provide('ol.ViewHint');
@@ -43,18 +43,18 @@ ol.ViewHint = {
/**
* @classdesc
* An ol.View2D object represents a simple 2D view of the map.
* An ol.View object represents a simple 2D view of the map.
*
* This is the object to act upon to change the center, resolution,
* and rotation of the map.
*
* ### The view states
*
* An `ol.View2D` is determined by three states: `center`, `resolution`,
* An `ol.View` is determined by three states: `center`, `resolution`,
* and `rotation`. To each state corresponds a getter and a setter. E.g.
* `getCenter` and `setCenter` for the `center` state.
*
* An `ol.View2D` has a `projection`. The projection determines the
* An `ol.View` has a `projection`. The projection determines the
* coordinate system of the center, and its units determine the units of the
* resolution (projection units per pixel). The default projection is
* Spherical Mercator (EPSG:3857).
@@ -66,7 +66,7 @@ ol.ViewHint = {
* that is passed to a setter will effectively be the value set in the view,
* and returned by the corresponding getter.
*
* But an `ol.View2D` object also has a *resolution constraint*, a
* But an `ol.View` object also has a *resolution constraint*, a
* *rotation constraint* and a *center constraint*.
*
* As said above no constraints are applied when the setters are used to set
@@ -89,10 +89,10 @@ ol.ViewHint = {
*
* @constructor
* @extends {ol.Object}
* @param {olx.View2DOptions=} opt_options View2D options.
* @param {olx.View2DOptions=} opt_options View options.
* @todo api
*/
ol.View2D = function(opt_options) {
ol.View = function(opt_options) {
goog.base(this);
var options = goog.isDef(opt_options) ? opt_options : {};
@@ -111,7 +111,7 @@ ol.View2D = function(opt_options) {
values[ol.View2DProperty.PROJECTION] = ol.proj.createProjection(
options.projection, 'EPSG:3857');
var resolutionConstraintInfo = ol.View2D.createResolutionConstraint_(
var resolutionConstraintInfo = ol.View.createResolutionConstraint_(
options);
/**
@@ -132,9 +132,9 @@ ol.View2D = function(opt_options) {
*/
this.minZoom_ = resolutionConstraintInfo.minZoom;
var centerConstraint = ol.View2D.createCenterConstraint_(options);
var centerConstraint = ol.View.createCenterConstraint_(options);
var resolutionConstraint = resolutionConstraintInfo.constraint;
var rotationConstraint = ol.View2D.createRotationConstraint_(options);
var rotationConstraint = ol.View.createRotationConstraint_(options);
/**
* @private
@@ -153,7 +153,7 @@ ol.View2D = function(opt_options) {
goog.isDef(options.rotation) ? options.rotation : 0;
this.setValues(values);
};
goog.inherits(ol.View2D, ol.Object);
goog.inherits(ol.View, ol.Object);
/**
@@ -161,7 +161,7 @@ goog.inherits(ol.View2D, ol.Object);
* @param {ol.Coordinate} anchor Rotation anchor.
* @return {ol.Coordinate|undefined} Center for rotation and anchor.
*/
ol.View2D.prototype.calculateCenterRotate = function(rotation, anchor) {
ol.View.prototype.calculateCenterRotate = function(rotation, anchor) {
var center;
var currentCenter = this.getCenter();
if (goog.isDef(currentCenter)) {
@@ -178,7 +178,7 @@ ol.View2D.prototype.calculateCenterRotate = function(rotation, anchor) {
* @param {ol.Coordinate} anchor Zoom anchor.
* @return {ol.Coordinate|undefined} Center for resolution and anchor.
*/
ol.View2D.prototype.calculateCenterZoom = function(resolution, anchor) {
ol.View.prototype.calculateCenterZoom = function(resolution, anchor) {
var center;
var currentCenter = this.getCenter();
var currentResolution = this.getResolution();
@@ -199,7 +199,7 @@ ol.View2D.prototype.calculateCenterZoom = function(resolution, anchor) {
* @return {ol.Coordinate|undefined} Constrained center.
* @todo api
*/
ol.View2D.prototype.constrainCenter = function(center) {
ol.View.prototype.constrainCenter = function(center) {
return this.constraints_.center(center);
};
@@ -212,7 +212,7 @@ ol.View2D.prototype.constrainCenter = function(center) {
* @return {number|undefined} Constrained resolution.
* @todo api
*/
ol.View2D.prototype.constrainResolution = function(
ol.View.prototype.constrainResolution = function(
resolution, opt_delta, opt_direction) {
var delta = opt_delta || 0;
var direction = opt_direction || 0;
@@ -227,7 +227,7 @@ ol.View2D.prototype.constrainResolution = function(
* @return {number|undefined} Constrained rotation.
* @todo api
*/
ol.View2D.prototype.constrainRotation = function(rotation, opt_delta) {
ol.View.prototype.constrainRotation = function(rotation, opt_delta) {
var delta = opt_delta || 0;
return this.constraints_.rotation(rotation, delta);
};
@@ -238,20 +238,20 @@ ol.View2D.prototype.constrainRotation = function(rotation, opt_delta) {
* @todo observable
* @todo api
*/
ol.View2D.prototype.getCenter = function() {
ol.View.prototype.getCenter = function() {
return /** @type {ol.Coordinate|undefined} */ (
this.get(ol.View2DProperty.CENTER));
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'getCenter',
ol.View2D.prototype.getCenter);
ol.View.prototype.getCenter);
/**
* @return {Array.<number>} Hint.
*/
ol.View2D.prototype.getHints = function() {
ol.View.prototype.getHints = function() {
return goog.array.clone(this.hints_);
};
@@ -263,7 +263,7 @@ ol.View2D.prototype.getHints = function() {
* @return {ol.Extent} Extent.
* @todo api
*/
ol.View2D.prototype.calculateExtent = function(size) {
ol.View.prototype.calculateExtent = function(size) {
goog.asserts.assert(this.isDef());
var center = this.getCenter();
var resolution = this.getResolution();
@@ -280,14 +280,14 @@ ol.View2D.prototype.calculateExtent = function(size) {
* @todo observable
* @todo api
*/
ol.View2D.prototype.getProjection = function() {
ol.View.prototype.getProjection = function() {
return /** @type {ol.proj.Projection|undefined} */ (
this.get(ol.View2DProperty.PROJECTION));
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'getProjection',
ol.View2D.prototype.getProjection);
ol.View.prototype.getProjection);
/**
@@ -295,14 +295,14 @@ goog.exportProperty(
* @todo observable
* @todo api
*/
ol.View2D.prototype.getResolution = function() {
ol.View.prototype.getResolution = function() {
return /** @type {number|undefined} */ (
this.get(ol.View2DProperty.RESOLUTION));
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'getResolution',
ol.View2D.prototype.getResolution);
ol.View.prototype.getResolution);
/**
@@ -313,7 +313,7 @@ goog.exportProperty(
* the given size.
* @todo api
*/
ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
ol.View.prototype.getResolutionForExtent = function(extent, size) {
var xResolution = ol.extent.getWidth(extent) / size[0];
var yResolution = ol.extent.getHeight(extent) / size[1];
return Math.max(xResolution, yResolution);
@@ -326,7 +326,7 @@ ol.View2D.prototype.getResolutionForExtent = function(extent, size) {
* @param {number=} opt_power Power.
* @return {function(number): number} Resolution for value function.
*/
ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) {
ol.View.prototype.getResolutionForValueFunction = function(opt_power) {
var power = opt_power || 2;
var maxResolution = this.maxResolution_;
var minResolution = this.minResolution_;
@@ -350,13 +350,13 @@ ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) {
* @todo observable
* @todo api
*/
ol.View2D.prototype.getRotation = function() {
ol.View.prototype.getRotation = function() {
return /** @type {number|undefined} */ (this.get(ol.View2DProperty.ROTATION));
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'getRotation',
ol.View2D.prototype.getRotation);
ol.View.prototype.getRotation);
/**
@@ -365,7 +365,7 @@ goog.exportProperty(
* @param {number=} opt_power Power.
* @return {function(number): number} Value for resolution function.
*/
ol.View2D.prototype.getValueForResolutionFunction = function(opt_power) {
ol.View.prototype.getValueForResolutionFunction = function(opt_power) {
var power = opt_power || 2;
var maxResolution = this.maxResolution_;
var minResolution = this.minResolution_;
@@ -385,9 +385,9 @@ ol.View2D.prototype.getValueForResolutionFunction = function(opt_power) {
/**
* @return {olx.ViewState} View2D state.
* @return {olx.ViewState} View state.
*/
ol.View2D.prototype.getState = function() {
ol.View.prototype.getState = function() {
goog.asserts.assert(this.isDef());
var center = /** @type {ol.Coordinate} */ (this.getCenter());
var projection = this.getProjection();
@@ -408,7 +408,7 @@ ol.View2D.prototype.getState = function() {
* @return {number|undefined} Zoom.
* @todo api
*/
ol.View2D.prototype.getZoom = function() {
ol.View.prototype.getZoom = function() {
var offset;
var resolution = this.getResolution();
@@ -434,7 +434,7 @@ ol.View2D.prototype.getZoom = function() {
* @param {ol.Size} size Box pixel size.
* @todo api
*/
ol.View2D.prototype.fitExtent = function(extent, size) {
ol.View.prototype.fitExtent = function(extent, size) {
if (!ol.extent.isEmpty(extent)) {
this.setCenter(ol.extent.getCenter(extent));
var resolution = this.getResolutionForExtent(extent, size);
@@ -453,10 +453,10 @@ ol.View2D.prototype.fitExtent = function(extent, size) {
* Take care on the map angle.
* @param {ol.geom.SimpleGeometry} geometry Geometry.
* @param {ol.Size} size Box pixel size.
* @param {olx.View2D.fitGeometryOptions=} opt_options Options.
* @param {olx.View.fitGeometryOptions=} opt_options Options.
* @todo api
*/
ol.View2D.prototype.fitGeometry = function(geometry, size, opt_options) {
ol.View.prototype.fitGeometry = function(geometry, size, opt_options) {
var options = goog.isDef(opt_options) ? opt_options : {};
var padding = goog.isDef(options.padding) ? options.padding : [0, 0, 0, 0];
@@ -523,7 +523,7 @@ ol.View2D.prototype.fitGeometry = function(geometry, size, opt_options) {
* @param {ol.Pixel} position Position on the view to center on.
* @todo api
*/
ol.View2D.prototype.centerOn = function(coordinate, size, position) {
ol.View.prototype.centerOn = function(coordinate, size, position) {
// calculate rotated position
var rotation = this.getRotation();
var cosAngle = Math.cos(-rotation);
@@ -546,7 +546,7 @@ ol.View2D.prototype.centerOn = function(coordinate, size, position) {
/**
* @return {boolean} Is defined.
*/
ol.View2D.prototype.isDef = function() {
ol.View.prototype.isDef = function() {
return goog.isDefAndNotNull(this.getCenter()) &&
goog.isDef(this.getResolution());
};
@@ -558,7 +558,7 @@ ol.View2D.prototype.isDef = function() {
* @param {ol.Coordinate=} opt_anchor The rotation center.
* @todo api
*/
ol.View2D.prototype.rotate = function(rotation, opt_anchor) {
ol.View.prototype.rotate = function(rotation, opt_anchor) {
if (goog.isDef(opt_anchor)) {
var center = this.calculateCenterRotate(rotation, opt_anchor);
this.setCenter(center);
@@ -573,13 +573,13 @@ ol.View2D.prototype.rotate = function(rotation, opt_anchor) {
* @todo observable
* @todo api
*/
ol.View2D.prototype.setCenter = function(center) {
ol.View.prototype.setCenter = function(center) {
this.set(ol.View2DProperty.CENTER, center);
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'setCenter',
ol.View2D.prototype.setCenter);
ol.View.prototype.setCenter);
/**
@@ -587,7 +587,7 @@ goog.exportProperty(
* @param {number} delta Delta.
* @return {number} New value.
*/
ol.View2D.prototype.setHint = function(hint, delta) {
ol.View.prototype.setHint = function(hint, delta) {
goog.asserts.assert(0 <= hint && hint < this.hints_.length);
this.hints_[hint] += delta;
goog.asserts.assert(this.hints_[hint] >= 0);
@@ -602,13 +602,13 @@ ol.View2D.prototype.setHint = function(hint, delta) {
* @todo observable
* @todo api
*/
ol.View2D.prototype.setProjection = function(projection) {
ol.View.prototype.setProjection = function(projection) {
this.set(ol.View2DProperty.PROJECTION, projection);
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'setProjection',
ol.View2D.prototype.setProjection);
ol.View.prototype.setProjection);
/**
@@ -617,13 +617,13 @@ goog.exportProperty(
* @todo observable
* @todo api
*/
ol.View2D.prototype.setResolution = function(resolution) {
ol.View.prototype.setResolution = function(resolution) {
this.set(ol.View2DProperty.RESOLUTION, resolution);
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'setResolution',
ol.View2D.prototype.setResolution);
ol.View.prototype.setResolution);
/**
@@ -632,13 +632,13 @@ goog.exportProperty(
* @todo observable
* @todo api
*/
ol.View2D.prototype.setRotation = function(rotation) {
ol.View.prototype.setRotation = function(rotation) {
this.set(ol.View2DProperty.ROTATION, rotation);
};
goog.exportProperty(
ol.View2D.prototype,
ol.View.prototype,
'setRotation',
ol.View2D.prototype.setRotation);
ol.View.prototype.setRotation);
/**
@@ -646,7 +646,7 @@ goog.exportProperty(
* @param {number} zoom Zoom level.
* @todo api
*/
ol.View2D.prototype.setZoom = function(zoom) {
ol.View.prototype.setZoom = function(zoom) {
var resolution = this.constrainResolution(
this.maxResolution_, zoom - this.minZoom_, 0);
this.setResolution(resolution);
@@ -654,11 +654,11 @@ ol.View2D.prototype.setZoom = function(zoom) {
/**
* @param {olx.View2DOptions} options View2D options.
* @param {olx.View2DOptions} options View options.
* @private
* @return {ol.CenterConstraintType}
*/
ol.View2D.createCenterConstraint_ = function(options) {
ol.View.createCenterConstraint_ = function(options) {
if (goog.isDef(options.extent)) {
return ol.CenterConstraint.createExtent(options.extent);
} else {
@@ -669,11 +669,11 @@ ol.View2D.createCenterConstraint_ = function(options) {
/**
* @private
* @param {olx.View2DOptions} options View2D options.
* @param {olx.View2DOptions} options View options.
* @return {{constraint: ol.ResolutionConstraintType, maxResolution: number,
* minResolution: number}}
*/
ol.View2D.createResolutionConstraint_ = function(options) {
ol.View.createResolutionConstraint_ = function(options) {
var resolutionConstraint;
var maxResolution;
var minResolution;
@@ -751,10 +751,10 @@ ol.View2D.createResolutionConstraint_ = function(options) {
/**
* @private
* @param {olx.View2DOptions} options View2D options.
* @param {olx.View2DOptions} options View options.
* @return {ol.RotationConstraintType} Rotation constraint.
*/
ol.View2D.createRotationConstraint_ = function(options) {
ol.View.createRotationConstraint_ = function(options) {
var enableRotation = goog.isDef(options.enableRotation) ?
options.enableRotation : true;
if (enableRotation) {