I'm using Angular 10 and ngx-leaflet. I have two points with lat and lng, how can I calculate distance (in meter) between these points? I need display it in template, is it some method to calculate it? Thanks.
Asked
Active
Viewed 147 times
-1
-
1https://leafletjs.com/reference-1.6.0.html#latlng-distanceto – IvanSanchez Sep 02 '20 at 13:32
-
U can have a look at this answer [here](https://stackoverflow.com/questions/639695/how-to-convert-latitude-or-longitude-to-meters). – Filip Filipovic Sep 02 '20 at 13:40
1 Answers
0
Instead of using a method to calculate the distance, you can simply use the coordinates of the two points you want to use and do a little bit of math. The formula to calculate the distance between two points in a 2D space is rather simple : Formula 1
But in a 3D space it's a bit more complicated, but still easy to use : Formula 2

lucasdctr
- 5
- 5