change size to optional

This commit is contained in:
cs09gi@gmail.com
2017-05-31 13:40:01 +09:00
parent 54a62ea78d
commit e8a2ad1d1b
+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);