Calculate a geodesic path between two points and measure its distance.

Use case
A geodesic distance provides an accurate, real-world distance between two points. Visualizing flight paths between cities is a common example of a geodesic operation since the flight path between two airports takes into account the curvature of the earth, rather than following the planar path between those points, which appears as a straight line on a projected map.
How to use the sample
Click anywhere on the map. A line graphic will display the geodesic line between the two points. In addition, text that indicates the geodesic distance between the two points will be updated. Click elsewhere and a new line will be created.
How it works
- Create a
Pointand display it as aGraphicwhen theMapViewis tapped. - Obtain a new point when another tap occurs on the
MapViewand add this point as a graphic. - Create a
Polylinefrom the two points. - Execute
GeometryEngine.geodeticDensify(_:maxSegmentLength:lengthUnit:curveType:)by passing in the created polyline then create a graphic from the returnedGeometry. - Execute
GeometryEngine.geodeticDistance(from:to:distanceUnit:azimuthUnit:curveType:)by passing in the two points and display the returned length on the screen.
Relevant API
- GeometryEngine.geodeticDensify(_:maxSegmentLength:lengthUnit:curveType:)
- GeometryEngine.geodeticDistance(from:to:distanceUnit:azimuthUnit:curveType:)
- MapView.onSingleTapGesture(perform:)
About the data
The Imagery basemap provides the global context for the displayed geodesic line.
Tags
densify, distance, geodesic, geodetic