I am trying to get a GeoJSON with projected coordinates to show in Leaflet.
I have no problems loading GeoJSON with lat/lng (EPSG:4326). Here is a fiddle where I load the GeoJSON with unprojected lat/lng.
I am using the Leaflet 1.0.0-beta.2 (954e83d) in the fiddle but I am happy to use another version.
I am aware of the coordsToLatLng method of L.geoJson but no idea how to make this work.
This is the GeoJSON with the projected (EPSG:3857) coordinates.
{
"type": "FeatureCollection",
"crs": {
"type": "name",
"properties": {
"name": "urn:ogc:def:crs:EPSG::3857"
}
},
"features": [{
"type": "Feature",
"properties": {
},
"geometry": {
"type": "Polygon",
"coordinates": [[
[-625570.6, 6465993.0],
[-305006.9, 6696510.8],
[-546330.2, 6768547.6],
[-445478.6, 7053093.0],
[-279794.0, 7056694.8],
[-359034.5, 7337638.4],
[-211359.0, 7485313.8],
[62380.8, 6955843.3],
[220861.7, 6909019.4],
[91195.5, 6700112.6],
[213658.1, 6682103.4],
[-625570.6, 6465993.0]]]
}
}]
}
Notes: I am new to Leaflet. I come from a GIS background. I have a very good understanding of projections and transformations. I have a very good understanding of OpenLayers3. I use OL3 to do things such as this on a daily basis. The data in this post is obviously just an example. I am trying to learn Leaflet in order to compare the performance with OL3. I know how to use QGIS and can unproject the data manually but this is not the point of this post.
This is not a repost. I have checked every bit of information on coordsToLatLng but didn't find any good documentation and nothing like a working example. Certainly no fiddle.
Just saying this as I have read a lot of Leaflet posts on gis.stackexchange with half-a-code. And a lot of answers which suggest to change the data. I know that Leaflet is not a GIS system and the makers are not from a GIS background. In the last hour I have just read a lot of rubbish about Leaflet using EPSG:3857 as default SRS and WGS84 being an SRS.