Add ol.Camera

This commit is contained in:
Tom Payne
2012-07-05 15:15:34 +02:00
committed by Tom Payne
parent c04e3d339f
commit dc2993b61d
3 changed files with 79 additions and 1 deletions

View File

@@ -135,7 +135,7 @@ Tile
fires 'aborted' // when loading is aborted
Camera
center goog.math.Coordinate
position goog.math.Coordinate
resolution number
rotation number

View File

@@ -1,6 +1,7 @@
goog.provide('ol');
goog.require('ol.Bounds');
goog.require('ol.Camera');
goog.require('ol.MVCArray');
goog.require('ol.MVCObject');
goog.require('ol.TileBounds');

77
src/ol/camera.js Normal file
View File

@@ -0,0 +1,77 @@
goog.provide('ol.Camera');
goog.require('goog.math.Coordinate');
goog.require('ol.MVCObject');
/**
* @enum {string}
* @private
*/
ol.CameraProperty_ = {
POSITION: 'center',
RESOLUTION: 'resolution',
ROTATION: 'rotation'
};
/**
* @constructor
* @extends {ol.MVCObject}
*/
ol.Camera = function() {
goog.base(this);
};
goog.inherits(ol.Camera, ol.MVCObject);
/**
* @return {goog.math.Coordinate} Position.
*/
ol.Camera.prototype.getPosition = function() {
return /** @type {goog.math.Coordinate} */ (
this.get(ol.CameraProperty_.POSITION));
};
/**
* @return {number} Resolution.
*/
ol.Camera.prototype.getResolution = function() {
return /** @type {number} */ (this.get(ol.CameraProperty_.RESOLUTION));
};
/**
* @return {number} Rotation.
*/
ol.Camera.prototype.getRotation = function() {
return /** @type {number} */ (this.get(ol.CameraProperty_.ROTATION));
};
/**
* @param {goog.math.Coordinate} position Position.
*/
ol.Camera.prototype.setPosition = function(position) {
this.set(ol.CameraProperty_.POSITION, position.clone());
};
/**
* @param {number} resolution Resolution.
*/
ol.Camera.prototype.setResolution = function(resolution) {
this.set(ol.CameraProperty_.RESOLUTION, resolution);
};
/**
* @param {number} rotation Rotation.
*/
ol.Camera.prototype.setRotation = function(rotation) {
this.set(ol.CameraProperty_.ROTATION, rotation);
};