描述
接收 Feature 或 FeatureCollection,返回保证位于要素表面上的 Point。
- 给定 Polygon,点将在多边形区域内
- 给定 LineString,点将沿字符串
- 给定 Point,点将与输入相同
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | 任何 Feature 或 FeatureCollection |
返回值
示例
javascript
var polygon = turf.polygon([
[
[116, -36],
[131, -32],
[146, -43],
[155, -25],
[133, -9],
[111, -22],
[116, -36],
],
]);
var pointOnPolygon = turf.pointOnFeature(polygon);安装
javascript
$ npm install @turf/point-on-feature
import { pointOnFeature } from "@turf/point-on-feature";
const result = pointOnFeature(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.pointOnFeature(...);