Appearance
KBE3D / KBCore / turf / centroid
函数: centroid()
centroid<
P>(geojson:AllGeoJSON,options?: {properties?:P; }):Feature<Point,P>
Function
Computes the centroid as the mean of all vertices within the object.
类型参数
P
P extends GeoJsonProperties = GeoJsonProperties
参数
geojson
GeoJSON to be centered
options?
Optional Parameters
properties?
P
an Object that is used as the Feature's properties
返回
the centroid of the input object
示例
ts
var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
var centroid = turf.centroid(polygon);
//addToMap
var addToMap = [polygon, centroid]