Debugged.

This commit is contained in:
Tim Schaub
2012-06-19 10:39:42 +02:00
parent 738561e417
commit 90f33c587a
6 changed files with 59 additions and 47 deletions

View File

@@ -1,23 +1,23 @@
goog.provide('ol.loc');
goog.require('ol.Location');
goog.require('ol.Loc');
/**
* @typedef {ol.Location|Array.<number>|{{x:number, y:number, z:number=, projection: ol.Projection=}}} loc Location.
* @typedef {ol.Loc|Array.<number>|Object} loc Location.
*/
ol.LocationLike;
ol.LocLike;
/**
* @export
* @param {ol.LocationLike} loc Location.
* @return {ol.Location} Location.
* @param {ol.LocLike} loc Location.
* @return {ol.Loc} Location.
*/
ol.loc = function(loc) {
if (loc instanceof ol.Location) {
if (loc instanceof ol.Loc) {
return loc;
}
@@ -53,7 +53,7 @@ ol.loc = function(loc) {
throw new Error('ol.loc');
}
return new ol.Location(x, y, z, projection);
return new ol.Loc(x, y, z, projection);
};
@@ -61,10 +61,10 @@ ol.loc = function(loc) {
/**
* @export
* @param {ol.Projection=} opt_arg Projection.
* @return {ol.Location|ol.Projection} Result.
* @return {ol.Loc|ol.Projection|undefined} Result.
*/
ol.Location.prototype.projection = function(opt_arg) {
if (arguments.length == 1) {
ol.Loc.prototype.projection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setProjection(opt_arg);
} else {
return this.getProjection();
@@ -75,10 +75,10 @@ ol.Location.prototype.projection = function(opt_arg) {
/**
* @export
* @param {number=} opt_arg X.
* @return {ol.Location|number} Result.
* @return {ol.Loc|number} Result.
*/
ol.Location.prototype.x = function(opt_arg) {
if (arguments.length == 1) {
ol.Loc.prototype.x = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setX(opt_arg);
} else {
return this.getX();
@@ -89,10 +89,10 @@ ol.Location.prototype.x = function(opt_arg) {
/**
* @export
* @param {number=} opt_arg Y.
* @return {ol.Location|number} Result.
* @return {ol.Loc|number} Result.
*/
ol.Location.prototype.y = function(opt_arg) {
if (arguments.length == 1) {
ol.Loc.prototype.y = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setY(opt_arg);
} else {
return this.getY();
@@ -103,10 +103,10 @@ ol.Location.prototype.y = function(opt_arg) {
/**
* @export
* @param {number=} opt_arg Z.
* @return {ol.Location|number} Result.
* @return {ol.Loc|number|undefined} Result.
*/
ol.Location.prototype.z = function(opt_arg) {
if (arguments.length == 1) {
ol.Loc.prototype.z = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setZ(opt_arg);
} else {
return this.getZ();

View File

@@ -1,6 +1,6 @@
goog.provide('ol.map');
goog.require('ol.Location');
goog.require('ol.Loc');
goog.require('ol.Map');
goog.require('ol.Projection');
goog.require('ol.loc');
@@ -18,7 +18,7 @@ ol.MapLike;
*/
ol.map = function(opt_arg) {
/** @type {ol.Location|undefined} */
/** @type {ol.Loc|undefined} */
var center;
var target;
@@ -43,3 +43,15 @@ ol.map = function(opt_arg) {
return map;
};
/**
* @param {ol.LocLike=} opt_arg
* @returns {ol.Map|ol.Loc|undefined} Map center.
*/
ol.Map.prototype.center = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setCenter(ol.loc(opt_arg));
} else {
return this.getCenter();
}
};