Skip to content

描述 ​

接收一个 Feature 或 FeatureCollection,返回所有要素的绝对中心点。

参数 ​

名称类型描述
geojsonGeoJSON待居中的 GeoJSON
options?Object可选参数 (默认 {})
options.properties?Object将 GeoJSON 属性转换到 Point (默认 {})
options.bbox?Object将 GeoJSON BBox 转换到 Point (默认 {})
options.id?Object将 GeoJSON Id 转换到 Point (默认 {})

返回值 ​

Feature<Point> 位于所有输入要素绝对中心点的 Point 要素

示例 ​

javascript
var features = turf.points([
  [-97.522259, 35.4691],
  [-97.502754, 35.463455],
  [-97.508269, 35.463245],
]);

var center = turf.center(features);

安装 ​

javascript
$ npm install @turf/center

import { center } from "@turf/center";
const result = center(...);
javascript
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.center(...);