Skip to content

KBE3D / KBCore / turf / midpoint

函数: midpoint()

midpoint(point1: Coord, point2: Coord): Feature<Point>

Function

Takes two points and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.

参数

point1

Coord

first point

point2

Coord

second point

返回

Feature<Point>

a point midway between pt1 and pt2

示例

ts
const point1 = turf.point([144.834823, -37.771257]);
const point2 = turf.point([145.14244, -37.830937]);

const midpoint = turf.midpoint(point1, point2);

//addToMap
const addToMap = [point1, point2, midpoint];
midpoint.properties['marker-color'] = '#f00';

KBE3D @3.0.0 Copyright © 2024-present KBE3D