Merge pull request #5352 from marlowp/Issue#5030
Add getResolutions() to ol.View
This commit is contained in:
@@ -134,6 +134,12 @@ ol.View = function(opt_options) {
|
||||
*/
|
||||
this.minResolution_ = resolutionConstraintInfo.minResolution;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {Array.<number>|undefined}
|
||||
*/
|
||||
this.resolutions_ = options.resolutions;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
@@ -313,6 +319,17 @@ ol.View.prototype.getResolution = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the resolutions for the view. This returns the array of resolutions
|
||||
* passed to the constructor of the {ol.View}, or undefined if none were given.
|
||||
* @return {Array.<number>|undefined} The resolutions of the view.
|
||||
* @api stable
|
||||
*/
|
||||
ol.View.prototype.getResolutions = function() {
|
||||
return this.resolutions_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get the resolution for a provided extent (in map units) and size (in pixels).
|
||||
* @param {ol.Extent} extent Extent.
|
||||
|
||||
@@ -268,6 +268,23 @@ describe('ol.View', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#getResolutions', function() {
|
||||
var view;
|
||||
var resolutions = [512, 256, 128, 64, 32, 16];
|
||||
|
||||
it('returns correct resolutions', function() {
|
||||
view = new ol.View({
|
||||
resolutions: resolutions
|
||||
});
|
||||
expect(view.getResolutions()).to.be(resolutions);
|
||||
});
|
||||
|
||||
it('returns resolutions as undefined', function() {
|
||||
view = new ol.View();
|
||||
expect(view.getResolutions()).to.be(undefined);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getZoom', function() {
|
||||
var view;
|
||||
beforeEach(function() {
|
||||
|
||||
Reference in New Issue
Block a user