com.supermap.web.mapping
public class GraphicsLayer
继承 GraphicsLayer Inheritance Layer Inheritance mx.core.UIComponent

高性能矢量渲染图层.

GraphicsLayer在轻量级交互操作的前提下,定位于流畅显示与浏览上万级矢量数据,并支持快速更新、选择、编辑数据。GraphicsLayer 结构图如下:

GraphicsLayer的基本显示单元为com.supermap.web.core.Graphic对象,目前支持数据更新(remove()/add()/removeAll()/refresh())、选择(GraphicClickHandler)两种交互操作。当用户需要实时动态刷新 Graphic 对象的 geometry/style 属性时,必须调用 GraphicsLayer.refresh()方法。
GraphicsLayerEvent辅助GraphicsLayer进行数据更新时派发操作数据,包括GRAPHICS_ADD(添加数据时派发)、GRAPHICS_REMOVE(删除数据时派发)、GRAPHICS_REMOVE_ALL(清空 GraphicsLayer 时派发)。
【注意】GraphicsLayer 的基本显示单元 Graphic 隶属于com.supermap.web.core命名空间,注意区别于 Adobe Flex SDK。

另请参见

com.supermap.web.core.Graphic
com.supermap.web.events.GraphicsLayerEvent


公共属性
  属性 定义方
  Inherited bounds : Rectangle2D
当前图层的地理范围,若当前图层为 Map 的第一个图层,且 Map 的 ViewBounds 为 null,则将当前图层的 bounds 作为 Map 的 ViewBounds。一般情况下该属性默认值为(0,0,0,0)。若当前图层为 WMTS 图层(TiledWMTSLayer),则 bounds 的默认值参考 WMTS 标准而定...
Layer
  Inherited CRS : CoordinateReferenceSystem
获取或设置当前图层的坐标参考系( CoordinateReferenceSystem )。默认值为 null。设置 CoordinateReferenceSystem.wkid 属性后,图层将被动态投影至 wkid 所代表的投影坐标系下,若 wkid 小于等于 0 则不进行动态投影...
Layer
    graphicClickHandler : Function
图形元素点击事件的侦听函数,当点击 GraphicsLayer 上的某一图形元素 Graphic 时,用户可通过该方法对选中的图形元素执行实际操作,如更改颜色、样式、显示弹窗信息等...
GraphicsLayer
    graphicItems : Array
[read-only] 图形元素集合,其类型为Array。
GraphicsLayer
  Inherited isInResolutionRange : Boolean
[read-only] 判断与当前图层关联的 Map 的分辨率是否在当前图层的最大、最小分辨率范围内。true 表示在最大、最小范围内。
Layer
  Inherited isScaleCentric : Boolean
[read-only] 指示该图层是否有 DPI 值,ture 表示当前图层已根据从 SuperMap iServer 服务端获取的参数计算出 DPI;false 反之。WMS、WMTS 等图层该属性值为 false。DynamicRESTLayer、TiledDynamicRESTLayer 等专门关联 SuperMap iServer 服务的图层该属性为 true。
Layer
  Inherited loaded : Boolean
[read-only] 若当前图层已加载完闭则返回 true,否则返回 false。
Layer
  Inherited maxVisibleResolution : Number
当前图层的最大显示分辨率。即当图层缩放至该分辨率时就不能再放大。
Layer
  Inherited metadata : Object
获取或设置当前图层信息,包括图层标题、描述信息、图层所在地图控件名称。
Layer
  Inherited minVisibleResolution : Number
当前图层的最小显示分辨率。即当图层缩放至该分辨率时就不能再缩小。
Layer
  Inherited resolution : Number
[read-only] 获取当前图层的显示分辨率。
Layer
  Inherited url : String
图层所在的服务地址。
Layer
  Inherited visible : Boolean
[Override] 获取或设置当前图层是否可见。
Layer
受保护的属性
  属性 定义方
  Inherited dpi : Number
获取当前图层的扫描精度,即单位面积内的像素的个数...
Layer
公共方法
  方法 定义方
   
初始化 GraphicsLayer 类的新实例。
GraphicsLayer
   
add(value:Array):void
添加 Graphic 数组。
GraphicsLayer
   
通过鼠标点来获取图形元素。
GraphicsLayer
  Inherited
refresh():void
刷新图层,即调用 Layer.invalidateDisplayList() 方法(详情请参见 Flex SDK UIComponent.invalidateDisplayList() 方法),更新 Layer 的显示列表。对于 GraphicsLayer 调用该方法会对 GraphicsLayer 上所有显示对象 Graphic 进行重绘。
Layer
   
remove(value:Array):void
删除 Graphic 数组。
GraphicsLayer
   
removeAll():void
删除 GraphicsLayer 上的所有图形元素。
GraphicsLayer
受保护的方法
  方法 定义方
  Inherited
addedHandler(event:Event):void
处理 Event.ADDED 事件的侦听器函数。
Layer
   
[Override] 为当前图层添加事件侦听器,以使侦听器能够接收 ZoomEvent、 ViewBoundsEvent 事件的触发通知。
GraphicsLayer
   
draw():void
[Override] 渲染出图,注意:子类必须重写该方法来实现渲染出图。
GraphicsLayer
  Inherited
hideHandler(event:FlexEvent):void
处理 FlexEvent.HIDE 事件的侦听器函数。
Layer
  Inherited
通过子类调用以更新图层。
Layer
  Inherited
删除 Layer 上的所有对象。
Layer
  Inherited
removedHandler(event:Event):void
处理 Event.REMOVED 事件的侦听器函数。
Layer
   
[Override] 移除通过 addMapListeners 添加的事件侦听器。
GraphicsLayer
  Inherited
setLoaded(value:Boolean):void
设置图层是否加载完闭,会触发 LayerEvent.LOAD 事件。true 表示当前图层已加载完毕。注意:任何继承 Layer 的子类都必须在 Layer 初始化完成之后调用该接口设置对应的图层是否加载完毕。
Layer
  Inherited
showHandler(event:FlexEvent):void
处理 FlexEvent.SHOW 事件的侦听器函数。
Layer
   
[Override] 处理 viewBoundsChanged 事件的侦听器函数。
GraphicsLayer
   
[Override] 处理 zoomEnd 事件的侦听器函数。
GraphicsLayer
   
[Override] 处理 zoomStart 事件的侦听器函数。
GraphicsLayer
  Inherited
处理 zoomUpdate 事件的侦听器函数。
Layer
事件
  事件 Summary 定义方
    Graphic 数组添加完成后派发。 GraphicsLayer
  Inherited 当 Layer 的 IsInResolutionRange 属性发生变化时触发该事件。 Layer
  Inherited 当图层初始化完成时触发该事件。 Layer
  Inherited 当载入图层出错时触发该事件。 Layer
  Inherited 当图层最大显示分辨率改变时触发该事件。 Layer
  Inherited 当图层最小显示分辨率改变时触发该事件。 Layer
    清空 GraphicsLayer 后派发。 GraphicsLayer
    Graphic 数组删除完成后派发。 GraphicsLayer
  Inherited 当完成更新图层时触发该事件。 Layer
  Inherited 当更新图层开始时触发该事件。 Layer
  Inherited 当图层的 visible 属性发生改变时触发该事件。 Layer
属性详细信息
graphicClickHandler 属性
graphicClickHandler:Function

图形元素点击事件的侦听函数,当点击 GraphicsLayer 上的某一图形元素 Graphic 时,用户可通过该方法对选中的图形元素执行实际操作,如更改颜色、样式、显示弹窗信息等...

示例代码如下:
private function graphicClick(graphic:Graphic):void
{
if (graphic.geometry is GeoRegion)
{
graphic.style = new GraphicFillStyle("solid", 0xffff00);
graphicsLayer.refresh();//此处必须调用refresh()方法
}
}
…………
graphicsLayer.graphicClickHandler = graphicClick;


Implementation
    public function get graphicClickHandler():Function
    public function set graphicClickHandler(value:Function):void
graphicItems 属性  
graphicItems:Array  [read-only]

图形元素集合,其类型为Array。


Implementation
    public function get graphicItems():Array
构造函数详细信息
GraphicsLayer () 构造函数
public function GraphicsLayer()

初始化 GraphicsLayer 类的新实例。

方法详细描述
add () 方法
public function add(value:Array):void

添加 Graphic 数组。

参数

value:Array — 被添加的数组对象,其中每个元素类型均为 Graphic。

另请参见

addMapListeners () 方法  
override protected function addMapListeners():void

为当前图层添加事件侦听器,以使侦听器能够接收 ZoomEvent、 ViewBoundsEvent 事件的触发通知。

draw () 方法  
override protected function draw():void

渲染出图,注意:子类必须重写该方法来实现渲染出图。

getGraphicByPoint () 方法  
public function getGraphicByPoint(point:Point):Graphic

通过鼠标点来获取图形元素。

参数

point:Point — 鼠标坐标点,类型为Point。

返回
Graphic

另请参见

remove () 方法  
public function remove(value:Array):void

删除 Graphic 数组。

参数

value:Array — 被删除的数组对象,其中每个元素类型均为 Graphic。

另请参见

removeAll () 方法  
public function removeAll():void

删除 GraphicsLayer 上的所有图形元素。

removeMapListeners () 方法  
override protected function removeMapListeners():void

移除通过 addMapListeners 添加的事件侦听器。

viewBoundsChangedHandler () 方法  
override protected function viewBoundsChangedHandler(event:ViewBoundsEvent):void

处理 viewBoundsChanged 事件的侦听器函数。

参数

event:ViewBoundsEvent — ViewBoundsEvent 事件类对象。

zoomEndHandler () 方法  
override protected function zoomEndHandler(event:ZoomEvent):void

处理 zoomEnd 事件的侦听器函数。

参数

event:ZoomEvent — ZoomEvent 事件类对象。

zoomStartHandler () 方法  
override protected function zoomStartHandler(event:ZoomEvent):void

处理 zoomStart 事件的侦听器函数。

参数

event:ZoomEvent — ZoomEvent 事件类对象。

事件详细信息
addComplete 事件
Event Object Type: com.supermap.web.events.GraphicsLayerEvent

Graphic 数组添加完成后派发。

removeAllComplete 事件  
Event Object Type: com.supermap.web.events.GraphicsLayerEvent

清空 GraphicsLayer 后派发。

removeComplete 事件  
Event Object Type: com.supermap.web.events.GraphicsLayerEvent

Graphic 数组删除完成后派发。