2

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?

1 Answer 1

1

This has been fixed in Leaflet after the 0.7.2 release.

1
  • 1
    fix is definitely there now, but it doesn't look like it made it into 0.7.3. Commented Sep 21, 2014 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.