Author: Charles F. F. Karney
Keywords: geodesics, geodesic distance, geographic distance, shortest path, direct geodesic problem, inverse geodesic problem, distance and azimuth, distance and heading, range and bearing, geographic circle, geodesic envelope, geodesic astroid, latitude and longitude, Google Maps, WGS84 ellipsoid, GeographicLib

## Geodesic lines, circles, envelopes in Google Maps (instructions)

The page allows you to draw accurate ellipsoidal geodesics on Google Maps. You can specify the geodesic in one of two forms:

- The direct problem: specify a starting point, an azimuth and a distance as lat1 lon1 azi1 s12 as degrees and meters.
- The inverse problem: specify the two end points as lat1 lon1 lat2 lon2 as degrees; this finds the shortest path between the two points.

(Angles may be entered as decimal degrees or as degrees, minutes, and seconds, e.g. -20.51125, 20°30′40.5″S, S20d30'40.5", or -20:30:40.5.) Click on the corresponding "compute" button. The display then shows

- The requested geodesic as a blue line; the WGS84 ellipsoid model is used.
- The geodesic circle as a green curve; this shows the locus of points a distance s12 from lat1, lon1.
- The geodesic envelopes as red curves; all the geodesics emanating from lat1, lon1 are tangent to the envelopes (providing they are extended far enough). The number of solutions to the inverse problem changes depending on whether lat2, lon2 lies inside the envelopes. For example, there are four (resp. two) approximately hemispheroidal geodesics if this point lies inside (resp. outside) the inner envelope (only one of which is a shortest path).

The sample data has lat1, lon1 in Wellington, New Zealand, lat2, lon2 in Salamanca, Spain, and s12 about 1.5 times the earth's circumference. Try clicking on the "compute" button next to the "Direct:" input box when the page first loads. You can navigate around the map using the normal Google Map controls.

The precision of output for the geodesic is 0.1" or 1 m. A text-only geodesic calculator based on the same JavaScript library is also available; this calculator solves the inverse and direct geodesic problems, computes intermediate points on a geodesic, and finds the area of a geodesic polygon; it allows you to specify the precision of the output and choose between decimal degrees and degrees, minutes, and seconds. Basic online tools which provide similar capabilities are GeodSolve and Planimeter; these call a C++ backend.

The JavaScript code for computing the geodesic lines, circles, and envelopes available in the JavaScript package geographiclib, the geodesic routines in GeographicLib ( documentation). The algorithms are derived in

> Charles F. F. Karney,
> Algorithms for geodesics,
> J. Geodesy 87(1), 43–55 (Jan. 2013);
> DOI: 10.1007/s00190-012-0578-z (pdf);
> addenda: geod-addenda.html.

In putting together this Google Maps demonstration, I started with the sample code geometry-headings.

Geographiclib Sourceforge