When I use the Mapbox Leaflet pre-packaged Projection class SphericalMercator to project a lat/long coordinate into EPSG:3857 I have to multiply the result Leaflet provides by the earth's radius.
var latlng = L.latLng(45, -120);
var sphericalMercator = L.Projection.SphericalMercator.project(latlng);
The following is what Leaflet returns:
sperhicalMercator.x => -2.0943951023931953
sphericalMercator.y => 0.8813735870195429
But the actual answer is (-13358338.8952, 5621521.48619)
, which I got by multiplying the results returned by Leaflet by 6,378,137 (earth's radius in meters).
var actualAnswerX = sphericalMercator.x * 6378137;
var actualAnswerY = sphericalMercator.y * 6378137;
Am I missing something?
No comments:
Post a Comment