ol.View#fit -- fix docs and add assertions

This commit is contained in:
vmalaret
2015-05-12 13:15:21 -04:00
committed by Bart van den Eijnden
parent e7cd691362
commit 4d3e903670
3 changed files with 18 additions and 2 deletions

View File

@@ -436,6 +436,8 @@ ol.View.prototype.getZoom = function() {
/**
* Fit the given geometry or extent based on the given map size and border.
* The size is pixel deminsions of the box to fit the extent into.
* In most cases you will want to use the map size, that is `map.getSize()`.
* Take care on the map angle.
* @param {ol.geom.SimpleGeometry|ol.Extent} geometry Geometry.
* @param {ol.Size} size Box pixel size.
@@ -443,8 +445,11 @@ ol.View.prototype.getZoom = function() {
* @api
*/
ol.View.prototype.fit = function(geometry, size, opt_options) {
if (!(geometry instanceof ol.geom.SimpleGeometry)) {
goog.asserts.assert(goog.isArray(geometry),
'invalid extent or geometry');
goog.asserts.assert(!ol.extent.isEmpty(geometry),
'cannot fit empty extent');
geometry = ol.geom.Polygon.fromExtent(geometry);
}