new FeatureSet(options)
base/feature/FeatureSet.js, line 47
支持如下方法:
[1、通过ID寻找要素][3、从geoJSON对象中导入数据]
[4、导出为GeoJSON数据]
[5、将一个要素数组对象转为要素集合]
[6、导出一个JSON对像]
[7、克隆并返回新的要素集合]
[8、通过传入的json构造并返回一个新的几何对象]
要素集合类,示例如下:[初始化要素集合对象]
[ES5引入方式]:
zondy.FeatureSet()
[ES6引入方式]:
import { FeatureSet } from "@mapgis/webclient-common"
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
构造参数
|
Example
// ES5引入方式
const { FeatureSet } = zondy
// ES6引入方式
import { FeatureSet } from "@mapgis/webclient-common"
//创建要素集合
let featureSet = new FeatureSet({
//不填则创建一个随机的guid
id: "你的id",
//要素集合
features: []
})
Members
-
featuresArray
-
要素数组 default []
-
fieldsArray.<Object>
-
要素集字段信息
-
geometryTypeString
-
要素集合的几何对象类型
-
idString
-
要素集合的id default 随机id
-
spatialReferenceSpatialReference
-
要素集合的参考系 default new zondy.SpatialReference('EPSG:4326')
-
typeString
-
该类的类型 default FeatureCollection
Methods
-
FeatureSet.fromArray(features, featureSet)
base/feature/FeatureSet.js, line 281 -
Name Type Description featuresArray.<Object> | FeatureSet featureSetFeatureSet Returns:
FeatureSet 新的featureSet对象Example
将一个要素数组对象转为要素集合 // ES5引入方式 const { FeatureSet } = zondy // ES6引入方式 import { FeatureSet } from "@mapgis/webclient-common" featureSet = FeatureSet.fromArray( [ { "attributes": { "FID": 650, "CODE": "420000", "CAPNAME": "武汉市", "mpPerimeter": "38.93733309514808", "mpArea": "17.556751278282672", "mpLayer": "18", "NAME": "湖北省" }, "geometry": { "type": "Polygon", "coordinates": [[]] }, "symbol": null } ], new FeatureSet() ) -
FeatureSet.fromGeoJSON(geoJSON){Promise.<FeatureSet>}
base/feature/FeatureSet.js, line 219 -
Name Type Description geoJSONgeoJSON数据
Returns:
Type Description Promise.<FeatureSet> 返回FeatureSet Example
从geoJSON对象中导入数据 //数据格式参考https://geojson.org/ FeatureSet.fromGeoJSON({ //类型必须为FeatureCollection type: "FeatureCollection", //要素集合 features: [] }) -
FeatureSet.fromJSON(json)
base/feature/FeatureSet.js, line 201 -
Name Type Description jsonObject JSON对象
Example
通过传入的json构造并返回一个新的几何对象 // ES5引入方式 const { FeatureSet } = zondy // ES6引入方式 import { FeatureSet } from "@mapgis/webclient-common" const json = { //不填则创建一个随机的guid id: "你的id", //要素集合 features: [] } const featureSet = new FeatureSet.fromJSON(json) -
clone(){FeatureSet}
base/feature/FeatureSet.js, line 177 -
Returns:
Type Description FeatureSet 克隆后的新要素集合 Example
克隆并返回新的要素集合 let newFeatureSet = featureSet.clone(); -
findFeatureById(id)
base/feature/FeatureSet.js, line 140 -
Name Type Description id要素ID
Returns:
Feature 要素对象Example
通过ID寻找要素 let feature = featureSet.findFeatureById("要素id"); -
toGeoJSON(){Object}
base/feature/FeatureSet.js, line 230 -
Returns:
Type Description Object geoJSON数据 Example
导出为GeoJSON数据 let geojson = featureSet.toGeoJSON(); -
toJSON(){Object}
base/feature/FeatureSet.js, line 156 -
Returns:
Type Description Object JSON对像