描述
遍历任何 GeoJSON 对象中的每个几何体,类似于 Array.forEach()。
注意:嵌套的 GeometryCollections 不会被递归展开。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | FeatureCollection | Feature | Geometry | GeometryObject | Feature<GeometryCollection> | 任何 GeoJSON 对象 |
| callback | geomEachCallback | 接收 (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) 的方法 |
返回值
void
示例
javascript
var features = turf.featureCollection([
turf.point([26, 37], { foo: "bar" }),
turf.point([36, 53], { hello: "world" }),
]);
turf.geomEach(
features,
function (
currentGeometry,
featureIndex,
featureProperties,
featureBBox,
featureId,
) {
//=currentGeometry
//=featureIndex
//=featureProperties
//=featureBBox
//=featureId
},
);安装
javascript
$ npm install @turf/meta
import { geomEach } from "@turf/meta";
const result = geomEach(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.geomEach(...);