Skip to content

KBE3D / KBCore / turf / pointOnFeature

函数: pointOnFeature()

pointOnFeature(geojson: AllGeoJSON): Feature<Point>

Function

Takes a Feature or FeatureCollection and returns a Point guaranteed to be on the surface of the feature.

  • Given a Polygon, the point will be in the area of the polygon
  • Given a LineString, the point will be along the string
  • Given a Point, the point will the same as the input

参数

geojson

AllGeoJSON

any Feature or FeatureCollection

返回

Feature<Point>

a point on the surface of input

示例

ts
var polygon = turf.polygon([[
  [116, -36],
  [131, -32],
  [146, -43],
  [155, -25],
  [133, -9],
  [111, -22],
  [116, -36]
]]);

var pointOnPolygon = turf.pointOnFeature(polygon);

//addToMap
var addToMap = [polygon, pointOnPolygon];

KBE3D @3.0.0 Copyright © 2024-present KBE3D