Appearance
KBE3D / KBCore / turf / center
函数: center()
center<
P>(geojson:AllGeoJSON,options?: {properties?:P;bbox?:BBox;id?:Id; }):Feature<Point,P>
Function
Takes a Feature or FeatureCollection and returns the absolute center point of all features.
类型参数
P
P extends GeoJsonProperties = GeoJsonProperties
参数
geojson
GeoJSON to be centered
options?
Optional parameters
properties?
P
Translate GeoJSON Properties to Point
bbox?
Translate GeoJSON BBox to Point
id?
Translate GeoJSON Id to Point
返回
a Point feature at the absolute center point of all input features
示例
ts
var features = turf.points([
[-97.522259, 35.4691],
[-97.502754, 35.463455],
[-97.508269, 35.463245]
]);
var center = turf.center(features);
//addToMap
var addToMap = [features, center]
center.properties['marker-size'] = 'large';
center.properties['marker-color'] = '#000';