# nearestPoint

Takes a reference point and a FeatureCollection of Features with Point geometries and returns the point from the FeatureCollection closest to the reference. This calculation is geodesic.


参数 类型 描述
targetPoint Coord the reference point
points FeatureCollection <Point> against input point set


Feature <Point> - the closest point in the set to the reference point


var targetPoint = turf.point([112.015826, 36.074031], {"marker-color": "#F00"});
var points = turf.featureCollection([
    turf.point([105.142483, 35.834725]),
    turf.point([104.772949, 30.963027]),
    turf.point([110.907223, 33.09316])

var nearest = turf.nearestPoint(targetPoint, points);
npm install @turf/nearest-point
Last Updated: 1/19/2021, 10:59:20 AM