Debugged.
This commit is contained in:
@@ -1,23 +1,23 @@
|
|||||||
goog.provide('ol.loc');
|
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
|
* @export
|
||||||
* @param {ol.LocationLike} loc Location.
|
* @param {ol.LocLike} loc Location.
|
||||||
* @return {ol.Location} Location.
|
* @return {ol.Loc} Location.
|
||||||
*/
|
*/
|
||||||
ol.loc = function(loc) {
|
ol.loc = function(loc) {
|
||||||
|
|
||||||
if (loc instanceof ol.Location) {
|
if (loc instanceof ol.Loc) {
|
||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ ol.loc = function(loc) {
|
|||||||
throw new Error('ol.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
|
* @export
|
||||||
* @param {ol.Projection=} opt_arg Projection.
|
* @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) {
|
ol.Loc.prototype.projection = function(opt_arg) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
return this.setProjection(opt_arg);
|
return this.setProjection(opt_arg);
|
||||||
} else {
|
} else {
|
||||||
return this.getProjection();
|
return this.getProjection();
|
||||||
@@ -75,10 +75,10 @@ ol.Location.prototype.projection = function(opt_arg) {
|
|||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {number=} opt_arg X.
|
* @param {number=} opt_arg X.
|
||||||
* @return {ol.Location|number} Result.
|
* @return {ol.Loc|number} Result.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.x = function(opt_arg) {
|
ol.Loc.prototype.x = function(opt_arg) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
return this.setX(opt_arg);
|
return this.setX(opt_arg);
|
||||||
} else {
|
} else {
|
||||||
return this.getX();
|
return this.getX();
|
||||||
@@ -89,10 +89,10 @@ ol.Location.prototype.x = function(opt_arg) {
|
|||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {number=} opt_arg Y.
|
* @param {number=} opt_arg Y.
|
||||||
* @return {ol.Location|number} Result.
|
* @return {ol.Loc|number} Result.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.y = function(opt_arg) {
|
ol.Loc.prototype.y = function(opt_arg) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
return this.setY(opt_arg);
|
return this.setY(opt_arg);
|
||||||
} else {
|
} else {
|
||||||
return this.getY();
|
return this.getY();
|
||||||
@@ -103,10 +103,10 @@ ol.Location.prototype.y = function(opt_arg) {
|
|||||||
/**
|
/**
|
||||||
* @export
|
* @export
|
||||||
* @param {number=} opt_arg Z.
|
* @param {number=} opt_arg Z.
|
||||||
* @return {ol.Location|number} Result.
|
* @return {ol.Loc|number|undefined} Result.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.z = function(opt_arg) {
|
ol.Loc.prototype.z = function(opt_arg) {
|
||||||
if (arguments.length == 1) {
|
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||||
return this.setZ(opt_arg);
|
return this.setZ(opt_arg);
|
||||||
} else {
|
} else {
|
||||||
return this.getZ();
|
return this.getZ();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
goog.provide('ol.map');
|
goog.provide('ol.map');
|
||||||
|
|
||||||
goog.require('ol.Location');
|
goog.require('ol.Loc');
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.loc');
|
goog.require('ol.loc');
|
||||||
@@ -18,7 +18,7 @@ ol.MapLike;
|
|||||||
*/
|
*/
|
||||||
ol.map = function(opt_arg) {
|
ol.map = function(opt_arg) {
|
||||||
|
|
||||||
/** @type {ol.Location|undefined} */
|
/** @type {ol.Loc|undefined} */
|
||||||
var center;
|
var center;
|
||||||
var target;
|
var target;
|
||||||
|
|
||||||
@@ -43,3 +43,15 @@ ol.map = function(opt_arg) {
|
|||||||
return map;
|
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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
goog.provide('ol.Location');
|
goog.provide('ol.Loc');
|
||||||
|
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ goog.require('ol.Projection');
|
|||||||
* @param {number=} opt_z Z.
|
* @param {number=} opt_z Z.
|
||||||
* @param {ol.Projection=} opt_projection Projection.
|
* @param {ol.Projection=} opt_projection Projection.
|
||||||
*/
|
*/
|
||||||
ol.Location = function(x, y, opt_z, opt_projection) {
|
ol.Loc = function(x, y, opt_z, opt_projection) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -43,7 +43,7 @@ ol.Location = function(x, y, opt_z, opt_projection) {
|
|||||||
/**
|
/**
|
||||||
* @return {ol.Projection|undefined} Projection.
|
* @return {ol.Projection|undefined} Projection.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.getProjection = function() {
|
ol.Loc.prototype.getProjection = function() {
|
||||||
return this.projection_;
|
return this.projection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ ol.Location.prototype.getProjection = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {number} X.
|
* @return {number} X.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.getX = function() {
|
ol.Loc.prototype.getX = function() {
|
||||||
return this.x_;
|
return this.x_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ ol.Location.prototype.getX = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {number} Y.
|
* @return {number} Y.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.getY = function() {
|
ol.Loc.prototype.getY = function() {
|
||||||
return this.y_;
|
return this.y_;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,16 +67,16 @@ ol.Location.prototype.getY = function() {
|
|||||||
/**
|
/**
|
||||||
* @return {number|undefined} Z.
|
* @return {number|undefined} Z.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.getZ = function() {
|
ol.Loc.prototype.getZ = function() {
|
||||||
return this.z_;
|
return this.z_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Projection|undefined} projection Projection.
|
* @param {ol.Projection|undefined} projection Projection.
|
||||||
* @return {ol.Location} This.
|
* @return {ol.Loc} This.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.setProjection = function(projection) {
|
ol.Loc.prototype.setProjection = function(projection) {
|
||||||
this.projection_ = projection;
|
this.projection_ = projection;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -84,9 +84,9 @@ ol.Location.prototype.setProjection = function(projection) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} x X.
|
* @param {number} x X.
|
||||||
* @return {ol.Location} This.
|
* @return {ol.Loc} This.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.setX = function(x) {
|
ol.Loc.prototype.setX = function(x) {
|
||||||
this.x_ = x;
|
this.x_ = x;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -94,9 +94,9 @@ ol.Location.prototype.setX = function(x) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} y Y.
|
* @param {number} y Y.
|
||||||
* @return {ol.Location} This.
|
* @return {ol.Loc} This.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.setY = function(y) {
|
ol.Loc.prototype.setY = function(y) {
|
||||||
this.y_ = y;
|
this.y_ = y;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@@ -104,9 +104,9 @@ ol.Location.prototype.setY = function(y) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number|undefined} z Z.
|
* @param {number|undefined} z Z.
|
||||||
* @return {ol.Location} This.
|
* @return {ol.Loc} This.
|
||||||
*/
|
*/
|
||||||
ol.Location.prototype.setZ = function(z) {
|
ol.Loc.prototype.setZ = function(z) {
|
||||||
this.z_ = z;
|
this.z_ = z;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
goog.provide('ol.Map');
|
goog.provide('ol.Map');
|
||||||
|
|
||||||
goog.require('ol.Location');
|
goog.require('ol.Loc');
|
||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
|
|
||||||
|
|
||||||
@@ -18,9 +18,9 @@ ol.Map = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Location}
|
* @type {ol.Loc}
|
||||||
*/
|
*/
|
||||||
this.location_ = new ol.Location(0, 0);
|
this.location_ = new ol.Loc(0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -32,7 +32,7 @@ ol.Map = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {ol.Location} Location.
|
* @return {ol.Loc} Location.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCenter = function() {
|
ol.Map.prototype.getCenter = function() {
|
||||||
return this.center_;
|
return this.center_;
|
||||||
@@ -56,7 +56,7 @@ ol.Map.prototype.getZoom = function() {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Location} center Center.
|
* @param {ol.Loc} center Center.
|
||||||
* @return {ol.Map} This.
|
* @return {ol.Map} This.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.setCenter = function(center) {
|
ol.Map.prototype.setCenter = function(center) {
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
describe("ol.Location", function() {
|
describe("ol.Loc", function() {
|
||||||
|
|
||||||
it("allows flexible construction", function() {
|
it("allows flexible construction", function() {
|
||||||
var loc;
|
var loc;
|
||||||
|
|
||||||
// nowhere
|
// nowhere
|
||||||
loc = ol.loc();
|
loc = ol.loc();
|
||||||
expect(loc instanceof ol.Location).toBe(true);
|
expect(loc instanceof ol.Loc).toBe(true);
|
||||||
|
|
||||||
// obj config
|
// obj config
|
||||||
loc = ol.loc({x: 10, y: 20});
|
loc = ol.loc({x: 10, y: 20});
|
||||||
@@ -80,7 +80,7 @@ describe("ol.Location", function() {
|
|||||||
var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"});
|
var loc = ol.loc({x: 10, y: 20, projection: "EPSG:4326"});
|
||||||
var trans = loc.transform("EPSG:3857");
|
var trans = loc.transform("EPSG:3857");
|
||||||
|
|
||||||
expect(trans instanceof ol.Location).toBe(true);
|
expect(trans instanceof ol.Loc).toBe(true);
|
||||||
expect(trans.projection().code()).toBe("EPSG:3857");
|
expect(trans.projection().code()).toBe("EPSG:3857");
|
||||||
expect(trans.x().toFixed(3)).toBe("1113194.908");
|
expect(trans.x().toFixed(3)).toBe("1113194.908");
|
||||||
expect(trans.y().toFixed(3)).toBe("2273030.927");
|
expect(trans.y().toFixed(3)).toBe("2273030.927");
|
||||||
@@ -95,7 +95,7 @@ describe("ol.Location", function() {
|
|||||||
var loc = ol.loc({x: 1113195, y: 2273031, projection: "EPSG:3857"});
|
var loc = ol.loc({x: 1113195, y: 2273031, projection: "EPSG:3857"});
|
||||||
var trans = loc.transform("EPSG:4326");
|
var trans = loc.transform("EPSG:4326");
|
||||||
|
|
||||||
expect(trans instanceof ol.Location).toBe(true);
|
expect(trans instanceof ol.Loc).toBe(true);
|
||||||
expect(trans.projection().code()).toBe("EPSG:4326");
|
expect(trans.projection().code()).toBe("EPSG:4326");
|
||||||
expect(trans.x().toFixed(3)).toBe("10.000");
|
expect(trans.x().toFixed(3)).toBe("10.000");
|
||||||
expect(trans.y().toFixed(3)).toBe("20.000");
|
expect(trans.y().toFixed(3)).toBe("20.000");
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-110.000");
|
expect(center.x().toFixed(3)).toBe("-110.000");
|
||||||
expect(center.y().toFixed(3)).toBe("45.000");
|
expect(center.y().toFixed(3)).toBe("45.000");
|
||||||
expect(center instanceof ol.Location).toBe(true);
|
expect(center instanceof ol.Loc).toBe(true);
|
||||||
|
|
||||||
// with object literal
|
// with object literal
|
||||||
map.center({x: -111, y: 46});
|
map.center({x: -111, y: 46});
|
||||||
@@ -29,7 +29,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-111.000");
|
expect(center.x().toFixed(3)).toBe("-111.000");
|
||||||
expect(center.y().toFixed(3)).toBe("46.000");
|
expect(center.y().toFixed(3)).toBe("46.000");
|
||||||
expect(center instanceof ol.Location).toBe(true);
|
expect(center instanceof ol.Loc).toBe(true);
|
||||||
|
|
||||||
// more verbose
|
// more verbose
|
||||||
map = ol.map({
|
map = ol.map({
|
||||||
@@ -39,7 +39,7 @@ describe("ol.Map", function() {
|
|||||||
center = map.center();
|
center = map.center();
|
||||||
expect(center.x().toFixed(3)).toBe("-112.000");
|
expect(center.x().toFixed(3)).toBe("-112.000");
|
||||||
expect(center.y().toFixed(3)).toBe("47.000");
|
expect(center.y().toFixed(3)).toBe("47.000");
|
||||||
expect(center instanceof ol.Location).toBe(true);
|
expect(center instanceof ol.Loc).toBe(true);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user