Skip to content

Commit

Permalink
API: expose a zoomToGeometryOrExtent function like OL fit() function
Browse files Browse the repository at this point in the history
  • Loading branch information
nboisteault committed Oct 22, 2024
1 parent 7bb076d commit be278ff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions assets/src/modules/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit be278ff

Please sign in to comment.