-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
L.Proj.CRS is missing distance method #109
Comments
Updated the gist http://bl.ocks.org/emacgillavry/1a654b76d35deceb9bec. The scalebar does appear and no error message. However, I simply get the stock image it seems: no lengths indicated. Am I missing something? |
Yeah, Again, this is super-ugly, but works as a workaround:
|
Updated the gist and it works beatifully. Have added 100 meter grid layer On 15 December 2015 at 13:58, Per Liedman notifications@github.com wrote:
|
Any hope of fixing this? It holds back the release of a branch compatible with leaflet 1.0.0 beta, #90. |
Closed in #126. |
In Leaflet 1.0, a CRS is expected to implement the method
distance
, which calculates the distance between twoL.LatLng
s, see L.CRS.Earth for example.I think the easy and "correct enough" fix is to just set
L.Proj.CRS.distance = L.CRS.Earth.distance
, which will use the haversine formula for all projections.An alternative, more complicated, but at least in some sense more correct solution, which uses the fact that distances are preserved by some projections, would be to project each LatLng, finding the differences dx and dy and doing
d = Math.sqrt(dx*dx+dy*dy)
, but some problems need to be solved:distance
still returns its result in metersI'd vote for just using
L.CRS.Earth.distance
until we find some use case were it would cause a problem.The text was updated successfully, but these errors were encountered: