From be278ff02fb5ee0dd7e5fbdf380c972c1059b909 Mon Sep 17 00:00:00 2001 From: nboisteault Date: Tue, 22 Oct 2024 11:04:45 +0200 Subject: [PATCH] API: expose a `zoomToGeometryOrExtent` function like OL fit() function Ref: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#fit --- assets/src/modules/map.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/assets/src/modules/map.js b/assets/src/modules/map.js index 38c297ccc1..9b21c8b919 100644 --- a/assets/src/modules/map.js +++ b/assets/src/modules/map.js @@ -1074,4 +1074,13 @@ export default class map extends olMap { removeToolLayer(layer) { this._toolsGroup.getLayers().remove(layer); } + + /** + * Zoom to given geometry or extent + * @param {import("ol/geom/SimpleGeometry.js").default|import("ol/extent.js").Extent} geometryOrExtent The geometry or extent to zoom to. + * @param {object} [options] Options. + */ + zoomToGeometryOrExtent(geometryOrExtent, options) { + this.getView().fit(geometryOrExtent, options); + } }