implement getMaxRes, getMaxExtent, getResForZoom
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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user