Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide method for transforming extent #171

Open
paul121 opened this issue Jul 12, 2022 · 2 comments · May be fixed by #189
Open

Provide method for transforming extent #171

paul121 opened this issue Jul 12, 2022 · 2 comments · May be fixed by #189

Comments

@paul121
Copy link
Member

paul121 commented Jul 12, 2022

I would like to get the lat/lon for the four corners of the current view's extent. This s.o. explains how it can be done: https://stackoverflow.com/questions/28166471/openlayer3-how-to-get-coordinates-of-viewport

Unfortunately var extent = map.getView().calculateExtent(map.getSize()); returns an extent in EPSG:3857 not EPSG:4326. OL has a method for transforming extents: extent = ol.proj.transformExtent(extent, 'EPSG:3857', 'EPSG:4326'); but because farmOS-map does not export this function it is not accessible without bundling parts of OL myself.

Could we either export this function and make it available at window.farmOS.map or make it available on the farmOS-map instance itself?

@paul121
Copy link
Member Author

paul121 commented Jul 12, 2022

I'm hoping to find an alternative solution to the use-case I described above but it seems that this would be a useful function to have available

@paul121
Copy link
Member Author

paul121 commented Feb 23, 2023

It would also be convenient to have the basic transform function so you can convert an OL coordinate to lat/lon. Common uses may be the center of the view or the event.coordinate when clicking on the map.

https://openlayers.org/en/latest/apidoc/module-ol_proj.html#.transform

paul121 added a commit to paul121/farmOS-map that referenced this issue Feb 27, 2023
paul121 added a commit to paul121/farmOS-map that referenced this issue Feb 27, 2023
@paul121 paul121 linked a pull request Feb 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant