Merge branch 'three' of https://github.com/tschaub/openlayers into three

Conflicts:
	src/api/loc.js
	src/api/map.js
	src/ol/Map.js
This commit is contained in:
Mike Adair
2012-06-19 09:04:04 -04:00
7 changed files with 65 additions and 102 deletions

View File

@@ -49,12 +49,7 @@ ol.bounds = function(opt_arg){
throw new Error('ol.bounds');
}
var bounds = new ol.Bounds();
bounds.setMinX(minX);
bounds.setMinY(minY);
bounds.setMaxX(maxX);
bounds.setMaxY(maxY);
bounds.setProjection(projection);
var bounds = new ol.Bounds(minX, minY, maxX, maxY, projection);
return bounds;
};

View File

@@ -1,6 +1,7 @@
goog.provide('ol.loc');
goog.require('ol.Loc');
goog.require('ol.projection');
/**
@@ -12,13 +13,13 @@ ol.LocLike;
/**
* @export
* @param {ol.LocLike} loc Location.
* @param {ol.LocLike} opt_arg Location.
* @return {ol.Loc} Location.
*/
ol.loc = function(loc){
ol.loc = function(opt_arg){
if (loc instanceof ol.Loc) {
return loc;
if (opt_arg instanceof ol.Loc) {
return opt_arg;
}
var x = 0;
@@ -26,37 +27,28 @@ ol.loc = function(loc){
var z;
var projection;
if (goog.isArray(loc)) {
if (loc.length >= 1) {
x = loc[0];
if (loc.length >= 2) {
y = loc[1];
if (loc.length >= 3) {
z = loc[2];
}
}
}
}
else
if (goog.isObject(loc)) {
if (goog.isDef(loc.x)) {
x = loc.x;
}
if (goog.isDef(loc.y)) {
y = loc.y;
}
if (goog.isDef(loc.z)) {
z = loc.z;
}
if (goog.isDef(loc.projection)) {
projection = loc.projection;
}
}
else {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
if (goog.isArray(opt_arg)) {
x = opt_arg[0];
y = opt_arg[1];
z = opt_arg[2];
projection = opt_arg[3];
} else if (goog.isObject(opt_arg)) {
x = opt_arg['x'];
y = opt_arg['y'];
z = opt_arg['z'];
projection = opt_arg['projection'];
} else {
throw new Error('ol.loc');
}
}
if (goog.isDef(projection)) {
projection = ol.projection(projection);
}
return new ol.Loc(x, y, z, projection);
var loc = new ol.Loc(x, y, z, projection);
return loc;
};
@@ -68,7 +60,7 @@ ol.loc = function(loc){
*/
ol.Loc.prototype.projection = function(opt_arg){
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setProjection(opt_arg);
return this.setProjection(ol.projection(opt_arg));
}
else {
return this.getProjection();

View File

@@ -19,57 +19,38 @@ ol.MapLike;
*/
ol.map = function(opt_arg){
/** @type {ol.Loc|undefined} */
var center;
/** @type {number|undefined} */
var zoom;
/** @type {number|undefined} */
var numZoomLevels;
/** @type {ol.Projection|undefined} */
var projection;
var target;
var map = new ol.Map();
var zoom;
if (arguments.length == 1) {
if (opt_arg instanceof ol.Map) {
return opt_arg;
}
else
if (goog.isObject(opt_arg)) {
var config = opt_arg;
if (goog.isDef(config.center)) {
center = ol.loc(config.center);
map.setCenter(center);
}
if (goog.isDef(config.zoom)) {
zoom = config.zoom;
map.setZoom(zoom);
}
if (goog.isDef(config.numZoomLevels)) {
numZoomLevels = config.numZoomLevels;
map.setNumZoomLevels(numZoomLevels);
}
if (goog.isDef(config.projection)) {
projection = config.projection;
map.setProjection(projection);
}
if (goog.isDef(config.target)) {
target = config.target;
}
}
else {
throw new Error('ol.map');
}
else if (goog.isObject(opt_arg)) {
center = opt_arg['center'];
target = opt_arg['target'];
zoom = opt_arg['zoom'];
}
else {
throw new Error('ol.map');
}
}
var map = new ol.Map();
if (goog.isDef(center)) {
map.setCenter(ol.loc(center));
}
if (goog.isDef(zoom)) {
map.setZoom(zoom);
}
return map;
};
/**
* @param {ol.LocLike=} opt_arg Get or set the map center.
* @returns {ol.Map|ol.Loc|undefined} The map center, or the map on set.
* @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)) {
@@ -80,8 +61,8 @@ ol.Map.prototype.center = function(opt_arg) {
};
/**
* @param {ol.Projection|string|undefined} opt_arg Get or set the map projection.
* @returns {ol.Map|number|undefined} the current zoom level, or the map on set.
* @param {ol.ProjectionLike=} opt_arg
* @returns {ol.Map|ol.Projection|undefined}
*/
ol.Map.prototype.projection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
@@ -93,7 +74,7 @@ ol.Map.prototype.projection = function(opt_arg) {
/**
* @param {ol.ProjectionLike=} opt_arg
* @returns {ol.Map|ol.Loc|undefined}
* @returns {ol.Map|ol.Projection|undefined}
*/
ol.Map.prototype.userProjection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
@@ -104,8 +85,8 @@ ol.Map.prototype.userProjection = function(opt_arg) {
};
/**
* @param {number|undefined} opt_arg Get or set the current zoom level.
* @returns {ol.Map|number|undefined} current zoom level on get or the map.
* @param {number=} opt_arg
* @returns {ol.Map|number|undefined} Map center.
*/
ol.Map.prototype.zoom = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
@@ -114,15 +95,3 @@ ol.Map.prototype.zoom = function(opt_arg) {
return this.getZoom();
}
};
/**
* @param {number|undefined} opt_arg Get or set the number of zoom levels.
* @returns {ol.Map|number|undefined} the number of zoom levels, or the map on set.
*/
ol.Map.prototype.numZoomLevels = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setNumZoomLevels(opt_arg);
} else {
return this.getNumZoomLevels();
}
};