# distance

Calculates the distance between two points in degrees, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature.
用度数、弧度、英里或公里计算两点之间的距离。

参数

参数 类型 描述
from Coord origin point
to Coord destination point
options Object Optional parameters: see below

options选项

属性 类型 默认值 描述
units string kilometers can be degrees, radians, miles, or kilometers

返回

number - distance between the two points

示例

var from = turf.point([-75.343, 39.984]);
var to = turf.point([-75.534, 39.123]);
var options = {units: 'miles'};

var distance = turf.distance(from, to, options);
Last Updated: 1/19/2021, 10:59:20 AM