kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
587 stars 172 forks source link

Convert LatLng array to a different CRS #186

Closed vorpalvorpal closed 7 months ago

vorpalvorpal commented 7 months ago

I've looked through the documentation and API, but can't seem to find anything.

I have a map in EPSG:3857, but I want a user to be able to click on a point and get a value returned as Eastings/Northings in EPSG:28356. I can get leaflet's LagLng array for the point, but there doesn't seem to be a simple way to then convert that array to a different CRS to report it to the user. Is this something that is possible to do using Proj4Leaflet, or is is outside of its scope?

perliedman commented 7 months ago

Hi there, a late reply and I guess you already solved this. There's no such functionality in proj4leaflet, and as you mention I think it probably outside the scope as well: Proj4Leaflet focuses on getting tiles and GeoJSON in other projections working in Leaflet, while this seems more of a general reprojection function.

If you already use Proj4Leaflet, you have Proj4js, which can do what you want, you'll just have to transform your LatLng instances to [lng, lat] arrays and pass each of them to a proj4 transform from WGS84 (EPSG:4326) to EPSG:28356. There should be examples in the Proj4js' docs.