Skip to main content
100%

distance(km) using haversine formula.

✓ Published0🌍 Public
Aandrewcowley
Last edited Oct 12, 2013
Created on Oct 12, 2013

This example calculates the great-circle distance between two geographic coordinates using the haversine formula. It shows the distance in kilometers between the Washington Monument area points [38.898556, -77.037852] and [38.897147, -77.043934]. The code defines a self-executing function that converts latitude and longitude differences to radians, applies the haversine equation with Earth’s mean radius (6371 km), and returns the result. It relies on native JavaScript Math methods (`cos`, `sin`, `atan2`, `sqrt`) without external libraries, and the output is a single numeric value representing the distance.

AI-generated description

Similar vizzes