Igor-Vladyka / leaflet.motion

A simple tool to animate polylines and polygons in different way
https://igor-vladyka.github.io/leaflet.motion/
MIT License
208 stars 44 forks source link

distance(<latLng>, <latLng>) vs. <latLng>.distanceTo(<latLng>) #9

Closed bsjones109 closed 4 years ago

bsjones109 commented 4 years ago

Hi, I noticed you are using latLng.distanceTo(latLng) in leaflet.motion.utils.js for distance calculation. The leaflet docs say this uses the spherical law of cosines for computation, where distance(latLng, latLng) uses a formula based on the map's CRS. I think the method used in leaflet.motion.utils.js will be inaccurate in some cases like CRS.Simple where the distance(latLng, latLng) formula would calculate the euclidean distance.

I'm not greatly familiar with CRS, but it seems like they're all using different types of projection, so I think it may be possible that the formula used in leaflet.motion.utils.js is only accurate for one of them.

Thanks for the great plugin!

Igor-Vladyka commented 4 years ago

Hi,

That is quite interesting, I heaven't checked it for a while. I will take a look and update you with findings.

Thanks :)

Igor-Vladyka commented 4 years ago

Hi again,

I just updated plugin with map.distance to unify animation across projections. It's in last released version 0.2.

Thanks for your help :)