Skip to content

KBE3D / KBCore / turf / centerMean

函数: centerMean()

centerMean<P>(geojson: any, options?: { properties?: P; bbox?: BBox; id?: Id; weight?: string; }): Feature<Point, P>

Function

Takes a Feature or FeatureCollection and returns the mean center. Can be weighted.

类型参数

P

P extends GeoJsonProperties = GeoJsonProperties

参数

geojson

any

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

weight?

string

the property name used to weight the center

返回

Feature<Point, P>

a Point feature at the mean center point of all input features

示例

ts
var features = turf.featureCollection([
  turf.point([-97.522259, 35.4691], {value: 10}),
  turf.point([-97.502754, 35.463455], {value: 3}),
  turf.point([-97.508269, 35.463245], {value: 5})
]);

var options = {weight: "value"}
var mean = turf.centerMean(features, options);

//addToMap
var addToMap = [features, mean]
mean.properties['marker-size'] = 'large';
mean.properties['marker-color'] = '#000';

KBE3D @3.0.0 Copyright © 2024-present KBE3D