Merge pull request #6863 from cs09g/cs09g-patch-1

change size to optional
This commit is contained in:
Andreas Hocevar
2017-05-31 13:37:52 +02:00
committed by GitHub
+4 -2
View File
@@ -662,11 +662,13 @@ ol.View.prototype.getResolutions = function() {
/** /**
* Get the resolution for a provided extent (in map units) and size (in pixels). * Get the resolution for a provided extent (in map units) and size (in pixels).
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {ol.Size} size Box pixel size. * @param {ol.Size=} opt_size Box pixel size.
* @return {number} The resolution at which the provided extent will render at * @return {number} The resolution at which the provided extent will render at
* the given size. * the given size.
* @api
*/ */
ol.View.prototype.getResolutionForExtent = function(extent, size) { ol.View.prototype.getResolutionForExtent = function(extent, opt_size) {
var size = opt_size || this.getSizeFromViewport_();
var xResolution = ol.extent.getWidth(extent) / size[0]; var xResolution = ol.extent.getWidth(extent) / size[0];
var yResolution = ol.extent.getHeight(extent) / size[1]; var yResolution = ol.extent.getHeight(extent) / size[1];
return Math.max(xResolution, yResolution); return Math.max(xResolution, yResolution);