-
Notifications
You must be signed in to change notification settings - Fork 25
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
Mesure-path with CRS.Simple #22
Comments
Hi there! It would be interesting to convert it to support other projections, and I think it would be fairly easy to fix this for line lengths. Polygon area is a bit trickier, since there's no built-in function in Leaflet for this, so Leaflet Measure Path has its own implementation: https://github.com/ProminentEdge/leaflet-measure-path/blob/master/leaflet-measure-path.js#L121 - we would need to make that possible to swap out. Given that I don't actively work on this plugin, I'm not in a position where I would make these changes, but I would be happy to guide you (other anyone else) if you would like fix this. |
Thank you, I will take a look at your code |
Hi, I did change the 291 line from: dist = ll1.distanceTo(ll2); to dist = this._map.distance(ll1, ll2); For the distribution example, the values result identical. For my map, using L.CRS.Simple, now shows the expected result. Explanation from Leaflet docs: distanceTo() - Returns the distance (in meters) to the given LatLng calculated using the Spherical Law of Cosines. distance() - Returns the distance between two geographical coordinates according to the map's CRS. By default this measures distance in meters. Maybe you can test this change in others maps and configurations Thank you |
@robjlg yes, sounds like a proper fix. Would you like to submit a PR? The only issue is that polygon areas will still be broken, but we could open a separate issue for that. |
For a simple polygon (https://en.wikipedia.org/wiki/Shoelace_formula) |
Hellow,
I'm very new to Leaflet.js and probably doing something wrong.
I'm using L.CRS.Simple to show a tiled image (non-geographical map). The L.control.scale shows the expected distance (2 m) but, mesure-path shows completed wrong values ( 119 km ! ).
Is it compatible with L.CRS.Simple ? Does mesure-path use the same approach L.control.scale uses to calculate distances?
Could you give me some tips on how to make mesure-path works correctly in this situation?
Thank You
Roberto
The text was updated successfully, but these errors were encountered: