I read everywhere that Leaflet is internally using a spherical web mercator (EPSG:3857), but whatever I try I get either Lat/Lon (EPSG:4326) or strange coordinates I dont understand:
map.getBounds().getNorthEast(); // LatLng(52.5262, 13.44907)map.getPixelBounds().getTopRight(); // Point(2253845, 1375425) ???map.getPixelOrigin(); // Point(2252165, 1375425) ???Let's try to project the spherical mercator:
L.Projection.SphericalMercator.project( map.getBounds().getNorthEast()); // Point(0.23473, 1.08117) !?!All right, there is a known bug in Leaflet 0.7.3, so let's add the earth radius:
L.point( L.Projection.SphericalMercator.project( map.getBounds().getNorthEast() ).x * 6378137.0, L.Projection.SphericalMercator.project( map.getBounds().getNorthEast() ).y * 6378137.0); // Point(1497143.40914, 6895833.38915)So, really, is it so hard to get the default projection coordinates of my map? Why do I have to call project() at all? What did I miss?
I am using leaflet 0.7.3 and did not change the CRS, using default EPSG:3857. Any ideas?
How to access Leaflet EPSG:3857 coordinates?
أكثر...
map.getBounds().getNorthEast(); // LatLng(52.5262, 13.44907)map.getPixelBounds().getTopRight(); // Point(2253845, 1375425) ???map.getPixelOrigin(); // Point(2252165, 1375425) ???Let's try to project the spherical mercator:
L.Projection.SphericalMercator.project( map.getBounds().getNorthEast()); // Point(0.23473, 1.08117) !?!All right, there is a known bug in Leaflet 0.7.3, so let's add the earth radius:
L.point( L.Projection.SphericalMercator.project( map.getBounds().getNorthEast() ).x * 6378137.0, L.Projection.SphericalMercator.project( map.getBounds().getNorthEast() ).y * 6378137.0); // Point(1497143.40914, 6895833.38915)So, really, is it so hard to get the default projection coordinates of my map? Why do I have to call project() at all? What did I miss?
I am using leaflet 0.7.3 and did not change the CRS, using default EPSG:3857. Any ideas?
How to access Leaflet EPSG:3857 coordinates?
أكثر...