new Feature(options)
base/feature/Feature.js, line 13
支持如下方法:
[1、从geoJSON对象中导入数据][2、导出为GeoJSON数据]
[3、通过传入的json构造并返回一个新的几何对象]
[4、导出一个JSON对像]
[5、克隆并返回新要素]
[6、导出为igs服务接口的要素对象]
[7、出为igs1.0服务接口的要素对象]
[8、导出为igs1.0的要素的图形信息]
[9、导出为igs1.0的要素的属性值]
[10、导出为igs1.0的要素的几何类型]
要素对象,示例如下:[初始化要素对象]
[ES5引入方式]:
zondy.Feature()
[ES6引入方式]:
import { Feature } from "@mapgis/webclient-common"
| Name | Type | Description | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
构造参数
|
Example
// ES5引入方式
const { Feature, Color } = zondy
const { LineString } = zondy.geometry
const { SimpleLineSymbol } = zondy.symbol
// ES6引入方式
import { Feature, Color, LineString, SimpleLineSymbol } from "@mapgis/webclient-common"
let feature = new Feature({
//不填则创建一个随机的guid
id: "你的id",
//设置属性
attributes: {},
//构建几何
geometry: new LineString({
coordinates: [[112.0, 30.0], [113.0, 30.0], [113.0, 31.0]]
}),
//设置样式
symbol: new SimpleLineSymbol({
//设置颜色
color: new Color(255, 0, 0, 1),
//设置线宽
width: 2
})
})
Members
-
additionalObject
-
额外属性,其中的arc3表示三点弧的信息
-
attributesObject
-
要素的属性 default {}
-
elevationInfoElevationInfo
-
高程模式参数
-
geometryGeometry
-
要素的几何对象
-
idString
-
要素id default 随机id
-
styleInfoObject
-
服务端要素的样式,用于IGS的要素编辑操作,具体参数说明请参考IGS文档
-
symbolSymbol
-
要素的样式
-
typeString
-
对象类型
-
visibleBoolean
-
要素是否可见 default = true
Methods
-
Feature.fromJSON(json)
base/feature/Feature.js, line 284 -
Name Type Description jsonObject JSON对象
Example
\ // ES5引入方式 const { LineString } = zondy.geometry const { Feature } = zondy // ES6引入方式 import { LineString, Feature } from "@mapgis/webclient-common" const json = { //设置属性 attributes: {}, //构建几何 geometry: new LineString({ coordinates: [[112.0, 30.0], [113.0, 30.0], [113.0, 31.0]] }) } const feature = new Feature.fromJSON(json)通过传入的json构造并返回一个新的几何对象 -
clone(){Feature}
base/feature/Feature.js, line 237 -
Returns:
Type Description Feature 克隆后的新要素 -
fromGeoJSON(geoJSON)
base/feature/Feature.js, line 351 -
Name Type Description geoJSONgeoJSON数据
Example
从geoJSON对象中导入数据 // ES5引入方式 const { Feature } = zondy // ES6引入方式 import { Feature } from "@mapgis/webclient-common" //数据格式参考https://geojson.org/ const feature = new Feature(); feature.fromGeoJSON({ type: "Feature", geometry: { type: "LineString", coordinates: [ [114.329481, 30.711953], [114.342372, 30.684553], [114.341474, 30.674527], [114.338273, 30.665863], [114.334533, 30.655893], [114.330017, 30.643386], [114.322936, 30.631171], [114.318749, 30.625032], [114.313923, 30.617818], [114.308156, 30.608404], [114.301348, 30.598718], [114.295038, 30.592581], [114.285992, 30.585234], [114.278415, 30.580865], [114.270119, 30.577433], [114.261901, 30.573909], [114.250444, 30.571547], [114.240741, 30.574025], [114.224975, 30.580306], [114.218822, 30.585491], [114.211532, 30.589347], [114.20474, 30.593382], [114.196667, 30.597536], [114.183062, 30.604521], [114.169464, 30.609907], [114.163868, 30.615064], [114.155941, 30.61846], [114.138907, 30.617699], [114.128567, 30.624968], [114.123644, 30.631684], [114.120804, 30.649056], [114.120828, 30.659055], ], }, properties: { ln: "1号线", su: "1", kn: "轨道交通1号线", ls: "420100034364", cl: "3080B7", la: "", x: 1, li: "420100034364|420100034365", color: "#3080B7", }, }); -
toAttValue(){Array}
base/feature/Feature.js, line 470 -
Returns:
Type Description Array igs1.0的要素的属性值 -
toFType(){Number}
base/feature/Feature.js, line 487 -
Returns:
Type Description Number igs1.0的要素的几何类型 -
toGeoJSON()
base/feature/Feature.js, line 374 -
Returns:
geoJSON geoJSON数据Example
导出为GeoJSON数据 //导出为GeoJSON数据 let geojson = feature.toGeoJSON(); -
toGraphicInfo(){Object}
base/feature/Feature.js, line 435 -
Returns:
Type Description Object igs1.0的要素的图形信息 -
toIGSFeature()
base/feature/Feature.js, line 390 -
Returns:
igs传输要素 -
toJSON(){Object}
base/feature/Feature.js, line 245 -
Returns:
Type Description Object JSON对像 -
toOldIGSFeature()
base/feature/Feature.js, line 420 -
Returns:
igs1.0的要素