Merge pull request #6260 from marcjansen/view-fit-docs
Enhance documentation for ol.View#fit
This commit is contained in:
@@ -670,18 +670,24 @@ ol.View.prototype.getZoom = function() {
|
|||||||
* The size is pixel dimensions of the box to fit the extent into.
|
* The size is pixel dimensions of the box to fit the extent into.
|
||||||
* In most cases you will want to use the map size, that is `map.getSize()`.
|
* In most cases you will want to use the map size, that is `map.getSize()`.
|
||||||
* Takes care of the map angle.
|
* Takes care of the map angle.
|
||||||
* @param {ol.geom.SimpleGeometry|ol.Extent} geometry Geometry.
|
* @param {ol.geom.SimpleGeometry|ol.Extent} geometryOrExtent The geometry or
|
||||||
* @param {ol.Size} size Box pixel size.
|
* extent to fit the view to.
|
||||||
|
* @param {ol.Size} size The size in pixels of the box to fit the extent into.
|
||||||
|
* Will often be `mep.getSize()`.
|
||||||
* @param {olx.view.FitOptions=} opt_options Options.
|
* @param {olx.view.FitOptions=} opt_options Options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.View.prototype.fit = function(geometry, size, opt_options) {
|
ol.View.prototype.fit = function(geometryOrExtent, size, opt_options) {
|
||||||
if (!(geometry instanceof ol.geom.SimpleGeometry)) {
|
/** @type {ol.geom.SimpleGeometry} */
|
||||||
ol.asserts.assert(Array.isArray(geometry),
|
var geometry;
|
||||||
|
if (!(geometryOrExtent instanceof ol.geom.SimpleGeometry)) {
|
||||||
|
ol.asserts.assert(Array.isArray(geometryOrExtent),
|
||||||
24); // Invalid extent or geometry provided as `geometry`
|
24); // Invalid extent or geometry provided as `geometry`
|
||||||
ol.asserts.assert(!ol.extent.isEmpty(geometry),
|
ol.asserts.assert(!ol.extent.isEmpty(geometryOrExtent),
|
||||||
25); // Cannot fit empty extent provided as `geometry`
|
25); // Cannot fit empty extent provided as `geometry`
|
||||||
geometry = ol.geom.Polygon.fromExtent(geometry);
|
geometry = ol.geom.Polygon.fromExtent(geometryOrExtent);
|
||||||
|
} else {
|
||||||
|
geometry = geometryOrExtent;
|
||||||
}
|
}
|
||||||
|
|
||||||
var options = opt_options || {};
|
var options = opt_options || {};
|
||||||
|
|||||||
Reference in New Issue
Block a user