forked from farmOS/farmOS-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getCurrentViewExtentCoordinates instance function farmOS#171
- Loading branch information
Showing
3 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
import { transformExtent } from 'ol/proj'; | ||
|
||
// Export OpenLayers transform functions | ||
export { transform, transformExtent } from 'ol/proj'; | ||
export { transform, transformExtent } from 'ol/proj'; | ||
|
||
/** | ||
* Returns the map's current view extent in the specified projection coordinates. | ||
* @param {import('ol/proj').ProjectionLike} source Source projection-like. | ||
* Defaults to 'EPSG:3857'. | ||
* @param {import('ol/proj').ProjectionLike} destination Destination projection-like. | ||
* Defaults to 'EPSG:4326'. | ||
* @return {import('ol/extent').Extent} The transformed extent. | ||
*/ | ||
export function getCurrentViewExtentCoordinates(source = 'EPSG:3857', destination = 'EPSG:4326') { | ||
const extent = this.map.getView().calculateExtent(this.map.getSize()); | ||
return transformExtent(extent, source, destination); | ||
} |