Merge branch 'master' of https://github.com/openlayers/ol3
This commit is contained in:
@@ -31,6 +31,8 @@ ol.map = function(opt_arg){
|
||||
var userProjection;
|
||||
/** @type {ol.Bounds|undefined} */
|
||||
var maxExtent;
|
||||
/** @type {ol.Bounds|undefined} */
|
||||
var maxRes;
|
||||
/** @type {Array.<number>|undefined} */
|
||||
var resolutions;
|
||||
/** @type {Array|undefined} */
|
||||
@@ -47,6 +49,7 @@ ol.map = function(opt_arg){
|
||||
projection = opt_arg['projection'];
|
||||
userProjection = opt_arg['userProjection'];
|
||||
maxExtent = opt_arg['maxExtent'];
|
||||
maxRes = opt_arg['maxRes'];
|
||||
resolutions = opt_arg['resolutions'];
|
||||
layers = opt_arg['layers'];
|
||||
}
|
||||
@@ -74,6 +77,9 @@ ol.map = function(opt_arg){
|
||||
if (goog.isDef(maxExtent)) {
|
||||
map.setMaxExtent(ol.bounds(maxExtent));
|
||||
}
|
||||
if (goog.isDef(maxRes)) {
|
||||
map.setMaxRes(maxRes);
|
||||
}
|
||||
if (goog.isDef(resolutions)) {
|
||||
map.setResolutions(resolutions);
|
||||
}
|
||||
@@ -187,3 +193,24 @@ ol.Map.prototype.maxExtent = function(opt_arg) {
|
||||
return this.getMaxExtent();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number=} opt_arg
|
||||
* @returns {ol.Map|number|undefined} Map maximum resolution
|
||||
*/
|
||||
ol.Map.prototype.maxRes = function(opt_arg) {
|
||||
if (arguments.length == 1 && goog.isDef(opt_arg)) {
|
||||
this.setMaxRes(opt_arg);
|
||||
return this;
|
||||
} else {
|
||||
return this.getMaxRes();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} arg
|
||||
* @returns {number} resolution for a given zoom level
|
||||
*/
|
||||
ol.Map.prototype.getResForZoom = function(arg) {
|
||||
return this.getResolutionForZoom(arg);
|
||||
};
|
||||
|
||||
@@ -21,6 +21,9 @@ ol.projection = function(opt_arg){
|
||||
/** @type {undefined|number} */
|
||||
var units;
|
||||
|
||||
/** @type {undefined|Array|ol.UnreferencedBounds} */
|
||||
var extent;
|
||||
|
||||
if (arguments.length == 1 && goog.isDefAndNotNull(opt_arg)) {
|
||||
if (opt_arg instanceof ol.Projection) {
|
||||
return opt_arg;
|
||||
@@ -35,13 +38,21 @@ ol.projection = function(opt_arg){
|
||||
throw new Error('Projection requires a string code.');
|
||||
}
|
||||
units = opt_arg['units'];
|
||||
extent = opt_arg['maxExtent'];
|
||||
}
|
||||
else {
|
||||
throw new Error('ol.projection');
|
||||
}
|
||||
}
|
||||
var proj = new ol.Projection(code);
|
||||
proj.setUnits(units);
|
||||
if (goog.isDef(units)) {
|
||||
proj.setUnits(units);
|
||||
}
|
||||
if (goog.isDef(extent)) {
|
||||
proj.setExtent(
|
||||
new ol.UnreferencedBounds(extent[0],extent[1],extent[2],extent[3])
|
||||
);
|
||||
}
|
||||
return proj;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,9 +33,9 @@ ol.Loc = function(x, y, opt_z, opt_projection) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.Projection|undefined}
|
||||
* @type {ol.Projection}
|
||||
*/
|
||||
this.projection_ = opt_projection;
|
||||
this.projection_ = goog.isDef(opt_projection) ? opt_projection : null;
|
||||
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ ol.Loc.prototype.getZ = function() {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Projection|undefined} projection Projection.
|
||||
* @param {ol.Projection} projection Projection.
|
||||
*/
|
||||
ol.Loc.prototype.setProjection = function(projection) {
|
||||
this.projection_ = projection;
|
||||
|
||||
@@ -42,16 +42,28 @@ ol.Map = function() {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array|undefined}
|
||||
* @type {Array}
|
||||
*/
|
||||
this.resolutions_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array|undefined}
|
||||
* @type {Array}
|
||||
*/
|
||||
this.layers_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.UnreferencedBounds}
|
||||
*/
|
||||
this.maxExtent_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.maxRes_ = undefined;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -64,7 +76,16 @@ ol.Map.prototype.DEFAULT_PROJECTION = "EPSG:3857";
|
||||
@type {string}
|
||||
*/
|
||||
ol.Map.prototype.DEFAULT_USER_PROJECTION = "EPSG:4326";
|
||||
|
||||
/**
|
||||
@const
|
||||
@type {number}
|
||||
*/
|
||||
ol.Map.ZOOM_FACTOR = 2;
|
||||
/**
|
||||
@const
|
||||
@type {number}
|
||||
*/
|
||||
ol.Map.DEFAULT_TILE_SIZE = 256;
|
||||
|
||||
/**
|
||||
* @return {ol.Loc} Location.
|
||||
@@ -145,6 +166,37 @@ ol.Map.prototype.getMaxExtent = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @return {number} the max resolution for the map
|
||||
*/
|
||||
ol.Map.prototype.getMaxRes = function() {
|
||||
if (goog.isDefAndNotNull(this.maxRes_)) {
|
||||
return this.maxRes_;
|
||||
} else {
|
||||
var extent = this.getMaxExtent();
|
||||
var dim = Math.max(
|
||||
(extent.getMaxX()-extent.getMinX()),
|
||||
(extent.getMaxY()-extent.getMinY())
|
||||
);
|
||||
return dim/ol.Map.DEFAULT_TILE_SIZE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} zoom the zoom level being requested
|
||||
* @return {number} the resolution for the map at the given zoom level
|
||||
*/
|
||||
ol.Map.prototype.getResolutionForZoom = function(zoom) {
|
||||
if (goog.isDefAndNotNull(this.resolutions_)) {
|
||||
return this.resolutions_[zoom];
|
||||
} else {
|
||||
var maxRes = this.getMaxRes();
|
||||
return maxRes/Math.pow(ol.Map.ZOOM_FACTOR, zoom);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Loc} center Center.
|
||||
*/
|
||||
@@ -199,12 +251,19 @@ ol.Map.prototype.setLayers = function(layers) {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ol.Bounds} extent the maxExtent for the map
|
||||
* @param {ol.UnreferencedBounds} extent the maxExtent for the map
|
||||
*/
|
||||
ol.Map.prototype.setMaxExtent = function(extent) {
|
||||
this.maxExtent_ = extent;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} res the max resolution for the map
|
||||
*/
|
||||
ol.Map.prototype.setMaxRes = function(res) {
|
||||
this.maxRes_ = res;
|
||||
};
|
||||
|
||||
/**
|
||||
*/
|
||||
ol.Map.prototype.destroy = function() {
|
||||
|
||||
@@ -21,15 +21,15 @@ ol.Projection = function(code) {
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!Object|undefined}
|
||||
* @type {Object}
|
||||
*/
|
||||
this.proj_ = undefined;
|
||||
this.proj_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {!ol.UnreferencedBounds|undefined}
|
||||
* @type {ol.UnreferencedBounds}
|
||||
*/
|
||||
this.extent_ = undefined;
|
||||
this.extent_ = null;
|
||||
|
||||
};
|
||||
|
||||
@@ -65,9 +65,18 @@ ol.Projection.prototype.setUnits = function(units) {
|
||||
/**
|
||||
* Get the validity extent of the coordinate reference system.
|
||||
*
|
||||
* @return {!ol.UnreferencedBounds|undefined} The valididty extent.
|
||||
* @return {ol.UnreferencedBounds} The valididty extent.
|
||||
*/
|
||||
ol.Projection.prototype.getExtent = function() {
|
||||
if (goog.isNull(this.extent_)) {
|
||||
var defs = ol.Projection['defaults'][this.code_];
|
||||
if (goog.isDef(defs)) {
|
||||
var ext = defs['maxExtent'];
|
||||
if (goog.isDef(ext)) {
|
||||
this.setExtent(new ol.UnreferencedBounds(ext[0],ext[1],ext[2],ext[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.extent_;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user