geovisearth / Exports / GraphicLayer

# Class: GraphicLayer

@类别 无需创建,引擎初始化时自动创建
@描述 几何绘制对象图层

示例代码
let engine = new GVOL.GvolEngine('GvolContainer');
let points = {
  gvolObject:{
    'gvolType': 'EditorPoint,
    "properties": {
    "pixelSize":20, //大小
    "color": '#FF0000', //颜色
    "outlineShow":true, //是否显示外边框
    "outlineWidth":2,
    "outlineColor":'#FFFFFF',
    "LabelName": "水体"
    },
    'geometry':{
      'coordinates':[86,30]
    }
  }
}
engine.graphicLayer.add(points,'point001','Point');

# Hierarchy

# Table of contents

# Accessors

# Methods

# Accessors

# Leafs

get Leafs(): any

叶子集合

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:194


# items

get items(): any[]

未分组标绘对象集合

# Returns

any[]

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:185

# Methods

# add

add(node): any

添加一个新节点

# Parameters

Name Type Description
node any 绘制数据对象或组对象

# Returns

any

示例代码
//添加绘制数据对象
 let obj = new GVOL.CylinderDynamicGraphic({
     topPosition: new GVOL.Core.GvolPoint(0,0,200000), 
     bottomPosition: new GVOL.Core.GvolPoint(0,0,0)
 })
 viewer.graphicLayer.add(obj);

//添加组对象并在组对象中添加标绘
  let group = new GVOL.Obj.GraphicGroup();
  viewer.graphicLayer.add(group);

  let polyline = new GVOL.Obj.PolylineGraphic({
     positions:[new GVOL.Core.GvolPoint(0,0,200000), new GVOL.Core.GvolPoint(100,0,200000)], 
     lineStyle: new GVOL.Obj.ColorStyle({color: '#ffff00'}),
     width: 3,
  });
  group.add(polyline);

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:131


# addGeojson

addGeojson(geojsonObj, objName, isVectorData?): any

基于参数的绘制 - geojson格式(非手动点击模式)

# Parameters

Name Type Default value
geojsonObj any undefined
objName string undefined
isVectorData boolean false

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:312


# contains

contains(gvolGuid): any

是否包含指定对象

# Parameters

Name Type
gvolGuid string | Object

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:264


# fire

fire(type, data): GraphicLayer

激活对象的某个监听事件,可以附件数据,并可以传递给父对象(事件对象基础方法)

Method

fire

# Parameters

Name Type Description
type string 事件名称
data any 监听时(on)收到的数据

# Returns

GraphicLayer

示例代码:
const info = {} //监听时(on)收到的数据
event.fire('add',info);

# Inherited from

Event.fire

# Defined in

Core/Event.ts:145


# fromJson

fromJson(json): void

导入json数据

# Parameters

Name Type
json object

# Returns

void

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:177


# getById

getById(id): any

根据ID获取对象

# Parameters

Name Type
id string

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:322


# getIgnoreById

getIgnoreById(id): any

根据ID获取对象

# Parameters

Name Type
id string

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:330


# getIgnoreRoot

getIgnoreRoot(): GraphicGroup

获取忽略根节点(该节点不会随整个场景反序列化)

# Returns

GraphicGroup

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:102


# getItemsInPolygon

getItemsInPolygon(positions): GvolObject[]

获取多边形内的标绘对象(目前仅支持单一坐标标绘)

See

获取区域内标绘对象

# Parameters

Name Type Description
positions GvolPoint[] 多边形位置点

# Returns

GvolObject[]

标会对象数组

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:508


# getLeaf

getLeaf(gvolGuid): any

获取Leaf

# Parameters

Name Type
gvolGuid any

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:203


# getNodeByName

getNodeByName(name): any[]

根据名称获取对象

# Parameters

Name Type
name string

# Returns

any[]

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:340


# getPlotJson

getPlotJson(plot): any

获取标绘对象的参数文件, json对象

# Parameters

Name Type
plot any

# Returns

any

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:285


# getRenderRoot

getRenderRoot(): Object

内部渲染对象使用

# Returns

Object

Name Type
billboardCollection BillboardCollection
entityRoot EntityCollection
labelCollection LabelCollection
postProcessStages any
primitiveRoot PrimitiveCollection

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:88


# getRoot

getRoot(): GraphicGroup

获取数据根节点

# Returns

GraphicGroup

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:95


# listens

listens(type): boolean

查询是否有指定类型的监听器(事件对象基础方法)

# Parameters

Name Type Description
type string 事件类型

# Returns

boolean

示例代码:
const hasListens = event.listens('add');

# Inherited from

Event.listens

# Defined in

Core/Event.ts:172


# off

off(type, fn, context?): void

移除对象的事件监听方法(事件对象基础方法)

# Parameters

Name Type Description
type string 要删除的监听事件类型
fn Function 要删除的监听回调函数,为空时清空所有回调函数
context? any 上下文

# Returns

void

代码示例:
event.off('add',fun);

# Inherited from

Event.off

# Defined in

Core/Event.ts:73


# on

on(type, fn, context?): GraphicLayer

添加对象的事件监听方法(事件对象基础方法)

# Parameters

Name Type Description
type string 监听事件类型
fn Function 监听回调函数
context? any 上下文 示例代码: const fun = function(info) { console.log('监听事件'); console.log(info); } event.on('add', fun); //监听添加事件

# Returns

GraphicLayer

# Inherited from

Event.on

# Defined in

Core/Event.ts:23


# pickByCoordinate

pickByCoordinate(x, y): GvolObject

根据屏幕坐标获取最上层绘制对象

# Parameters

Name Type Description
x number 屏幕坐标x
y number 屏幕坐标y

# Returns

GvolObject

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:411


# pickByCoordinate2

pickByCoordinate2(x, y): GvolObject[]

根据屏幕坐标获取绘制对象数组

# Parameters

Name Type
x number
y number

# Returns

GvolObject[]

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:401


# pickIgnoreByCoordinate

pickIgnoreByCoordinate(x, y): GvolObject

根据屏幕坐标获取最上层绘制对象

# Parameters

Name Type Description
x number 屏幕坐标x
y number 屏幕坐标y

# Returns

GvolObject

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:421


# pickRect

pickRect(x, y, width, height): GvolObject[]

拾取对象 返回plot对象

# Parameters

Name Type
x number
y number
width number
height number

# Returns

GvolObject[]

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:375


# remove

remove(plot): void

删除标绘对象

# Parameters

Name Type
plot any

# Returns

void

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:232


# removeAll

removeAll(): void

删除所有标绘对象

# Returns

void

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:214


# toJson

toJson(): object

导出json数据

# Returns

object

# Defined in

LayerManager/GraphicLayer/GraphicLayer.ts:170