Closed MuellerMatthew closed 6 years ago
I am having the same issue. Did you make a standard implementation?
I did not make a clean fix for this bug, I just modded leaflet to explicitly ignore the CRS when I am using this feature. If I have time later I might work on modding the Proj4Leaflet to fix this, but it isn't a pressing issue for me yet.
Looking at this a looong time later, is it correct that Leaflet for this case just outputs a standard GeoJSON with WGS84 coordinates, without any projection information?
That is what I'd assume it does, and I would also argue that it is the correct behavior, since these days WGS84 is the CRS for GeoJSON.
While I can see the need to export data in other CRS, I think it would be quirky at best to implement this: toGeoJSON
does not accept any options, so it's not easy to know which CRS to export to - notice that you can actually add different features with different CRS using Proj4Leaflet's GeoJSON
layer.
Also, it is complicated a lot by the fact that while Leaflet allows you to reproject coordinates when adding GeoJSON features, there is no corresponding method to reproject coordinates when serializing the to GeoJSON; unless such a function was added, Proj4Leaflet would have no easy way to do this.
Because of these reasons, I would argue this as outside the scope of Proj4Leaflet. For the not-so-common use case of having to export reprojected GeoJSON, I would recommend just using toGeoJSON
and then using a library like reproject to transform this GeoJSON into the desired projection.
I'm closing this for now, but feel free to nudge me if you think this is the wrong call of if I missed some simple solution.
Proj4 currently doesn't extend the toGeoJSON(). When exporting data added through Proj4Leaflet, the newly generated data being exported is in lat/lng coordinates but the CRS still refers to the the original projection.