Skip to content

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

AllGeoJSON

GeoJSON to be centered

options?

Optional parameters

properties?

P

Translate GeoJSON Properties to Point

bbox?

BBox

Translate GeoJSON BBox to Point

id?

Id

Translate GeoJSON Id to Point

返回

Feature<Point, P>

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';

KBE3D @3.0.0 Copyright © 2024-present KBE3D