Appearance
KBE3D / KBCore / turf / centerOfMass
函数: centerOfMass()
centerOfMass<
P>(geojson:any,options?: {properties?:P; }):Feature<Point,P>
Function
Takes any Feature or a FeatureCollection and returns its center of mass using this formula: Centroid of Polygon.
类型参数
P
P extends GeoJsonProperties = GeoJsonProperties
参数
geojson
any
GeoJSON to be centered
options?
Optional Parameters
properties?
P
Translate Properties to Feature
返回
the center of mass
示例
ts
var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
var center = turf.centerOfMass(polygon);
//addToMap
var addToMap = [polygon, center]