Skip to content

描述 ​

接收 Feature 或 FeatureCollection,返回保证位于要素表面上的 Point。

  • 给定 Polygon,点将在多边形区域内
  • 给定 LineString,点将沿字符串
  • 给定 Point,点将与输入相同

参数 ​

名称类型描述
geojsonGeoJSON任何 Feature 或 FeatureCollection

返回值 ​

Feature<Point> input 表面上的点

示例 ​

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(...);