new PrimitivePlot(viewer, options)
app/plotting/core/PrimitivePlot.js, line 71
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
viewer |
Viewer |
容器 |
||||||||||||||||||||
options |
Object |
标绘构造属性
|
Example
this.plot = new PrimitivePlot(window.viewer, {
usePrimitive: true,
useMeasure: true,
useContextMenu: true
})
this.infos = this.plot.data
this.canRedo = this.plot.canRedo
this.canUndo = this.plot.canUndo
this.plot.on('activated', e => {
console.log('activated:' + e)
e.forEach(item => {
if (item.type === 'Polyline2D' && item.subType === '') item.magnetic = 9
})
})
this.plot.on('deactivated', e => {
console.log('deactivated:' + e)
console.log('当前激活图形:' + this.plot.activeInstance)
})
this.plot.on('drawEnd', e => {
console.log(e.id)
})
this.plot.on('drawCancel', () => {
this.$message('取消')
})
this.plot.on('change', () => {
console.log('change...')
})
this.plot.on('changed', () => {
console.log('changed')
this.canRedo = this.plot.canRedo
this.canUndo = this.plot.canUndo
})
this.plot.on('destroyed', e => {
this.$message('已销毁')
console.log(e.id)
})
Classes
Members
-
activeDatas
-
激活图形的数据
-
activeGeoJSON
-
激活图形的GeoJSON数据
-
activeInstance
-
激活图形实例
Methods
-
activate(target)
app/plotting/core/PrimitivePlot.js, line 960 -
激活指定标绘
Name Type Description target
String | Array.<String> -
clear()
app/plotting/core/PrimitivePlot.js, line 802 -
清空所有标绘实例
-
deactivate(target)
app/plotting/core/PrimitivePlot.js, line 1049 -
取消激活指定标绘
Name Type Description target
String | Array.<String> -
asyncdraw(type, options)
app/plotting/core/PrimitivePlot.js, line 729 -
构建
Name Type Description type
String Billboard, Polygon2D, Polyline2D, Circle2D, Rectangle2D, Rectangle3D, Polygon3D, Circle3D, PolylineVolume, Wall,Corridor,Gltf
options
* Example
this.plot.draw(type, options).then(e => { this.canRedo = this.plot.canRedo this.canUndo = this.plot.canUndo })
-
export(){Array}
app/plotting/core/PrimitivePlot.js, line 1114 -
导出所有数据
Returns:
Type Description Array -
exportGeoJSON(){JSON}
app/plotting/core/PrimitivePlot.js, line 1125 -
导出所有数据(GeoJSON)
Returns:
Type Description JSON -
getGroup(groupId){Object}
app/plotting/core/PrimitivePlot.js, line 1137 -
返回一个指定 groupId 的 group
Name Type Description groupId
String | Number Returns:
Type Description Object -
getInstanceById(id){plotPrimitive}
app/plotting/core/PrimitivePlot.js, line 925 -
根据 id 获取实例
Name Type Description id
* Returns:
Type Description plotPrimitive -
read(data, groups, autoActive){Promise.<any>}
app/plotting/core/PrimitivePlot.js, line 508 -
read
Name Type Default Description data
* groups
* autoActive
Boolean false 导入后是否激活
Returns:
Type Description Promise.<any> Example
this.plot .read( [ const testCircle = { type: 'Polyline2D', width: 5, label: '我好久好久', positions: [ [120.46643560502625 + Math.random() * 0.1, 32.013940273291794 + Math.random() * 0.1, -3.7694021255259336], [120.5246623066096 + Math.random() * 0.1, 31.99516449647152 + Math.random() * 0.1, 0.3764073059303412], [120.52002352221018 + Math.random() * 0.1, 31.96288068137888 + Math.random() * 0.1, 1.1142658171278148], [120.49789474457651 + Math.random() * 0.1, 31.976075524467447 + Math.random() * 0.1, 1.925366493185131] ], color: 'rgba(255,255,0,1)', arrow: true }])
-
readGeoJSON(data, groups){Promise.<any>}
app/plotting/core/PrimitivePlot.js, line 567 -
readGeoJSON
Name Type Description data
* groups
* Returns:
Type Description Promise.<any> Example
this.plot.readGeoJSON({ type: 'FeatureCollection', features: [ { type: 'Feature', properties: { id: '200E567C-45F2-44F2-9855-44E1C9C94582', type: 'Rectangle2D', positions: [ [116.35531515, 39.93986238, 0], [116.35712949, 39.93858457, 0] ], coordArray: [ [116.35531515, 39.93986238, 0], [116.35712949, 39.93986238, 0], [116.35712949, 39.93858457, 0], [116.35531515, 39.93858457, 0] ], outlineColor: '#4680ff', outlineWidth: 3, measureLength: 593.9, measureArea: 22001.14, color: 'rgba(67, 110, 238, 0.4)' }, geometry: { type: 'Polygon', coordinates: [ [ [116.35531515, 39.93986238], [116.35712949, 39.93986238], [116.35712949, 39.93858457], [116.35531515, 39.93858457] ] ] } }]})
-
remove(id)
app/plotting/core/PrimitivePlot.js, line 853 -
移除标绘图形
Name Type Description id
String | Number Example
this.plot.activeInstance.forEach(instance => { this.plot.remove(instance.id) })