Any ideas on how to calculate the nautical miles using react? Assume that I have an object:
const calculateDistance = [
{point_id: 1, long: longitude , lat: latitude},
{point_id: 2, long: longitude , lat: latitude},
{point_id: 3, long: longitude , lat: latitude},
{point_id: 4, long: longitude , lat: latitude},
{point_id: 5, long: longitude , lat: latitude},
]
I would greatly appreciate any suggestions. Thank you!
2
Answers
React is a rendering library so you don’t calculate in React. However, you are using javascript or typescript and this you can use. Something like:
to calculate between 2 points using the https://en.wikipedia.org/wiki/Haversine_formula then you can add them if you need multiple points.
You calculate the distance using the haversine formula in react. Here is how:
I hope this helps!