描述
获取 GeoJSON 对象的类型,Geometry 类型优先。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeoJSON 对象 |
| _name? | string | |
| name? | string | 错误消息中显示的变量名(未使用) (默认 "geojson") |
返回值
string GeoJSON 类型
示例
javascript
var point = {
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: [110, 40],
},
};
var geom = turf.getType(point);
//="Point"安装
javascript
$ npm install @turf/invariant
import { getType } from "@turf/invariant";
const result = getType(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.getType(...);