MapLayerCollection

MapLayerCollection

地图图层集合。 不需要创建,直接从MainControl实例中获取即可。

Constructor

new MapLayerCollection(viewer, popups)

Author:
  • zpc
Example
// 从MainControl实例中获取矢量图层集合实例
var mapLayers = mainControl.mapLayers;
Parameters:
Name Type Description
viewer Cesium.Viewer Cesium视景器。
popups Popups 弹出框。

Members

enableFeatureSelection :Boolean

Default Value:
  • true
开启或关闭要素选择功能。
Type:
  • Boolean

(readonly) featureSelection :MapLayerFeatureSelection

获取要素选择实例对象。
Type:

layerAdded :Cesium.Event

Default Value:
  • Cesium.Event()
向集合中添加图层时触发的事件。 事件处理程序将传递添加的图层和在其上添加的索引。
Type:
  • Cesium.Event

layerMoved :Cesium.Event

Default Value:
  • Cesium.Event()
集合中的图层位置顺序发生改变时触发的事件。 事件处理程序将传递被移动的图层、在移动之后的新索引和在移动之前的旧索引。
Type:
  • Cesium.Event

layerRemoved :Cesium.Event

Default Value:
  • Cesium.Event()
从集合中移除图层时触发的事件。 事件处理程序将传递删除的图层和其索引。
Type:
  • Cesium.Event

length :Number

集合中图层的数量。
Type:
  • Number

show :Boolean

Default Value:
  • true
获取或设置图层集合是否显示。
Type:
  • Boolean

values :Array.<MapLayer>

集合中图层数组。无序数组。
Type:

Methods

add(mapLayer, indexopt) → {MapLayer}

向集合中添加一个图层。
Parameters:
Name Type Attributes Description
mapLayer MapLayer 要添加的图层。
index Number <optional>
图层的索引。如果省略则此图层添加到集合顶部。
Throws:
如果提供索引,则索引必须大于或等于0,并且小于或等于图层数。
Type
Cesium.DeveloperError
Returns:
添加的图层。
Type
MapLayer

addMapLoader(layerName, mapLoader, indexopt) → {MapLayer}

使用给定的MapLoader创建一个新图层,并将其添加到集合中。
Parameters:
Name Type Attributes Description
layerName String 图层名称。
mapLoader MapLoader 用来创建图层的地图加载器。
index Number <optional>
要添加的图层的索引。如果省略则此图层添加到集合顶部。
Returns:
创建的新图层。
Type
MapLayer

contains(mapLayer) → {Boolean}

检查集合中是否包含给定的图层。
Parameters:
Name Type Description
mapLayer MapLayer 要检查的图层。
Returns:
如果集合包含该图层,则为true,否则为false。
Type
Boolean

containsById(mapLayer) → {Boolean}

检查集合中是否包含给定ID的图层。
Parameters:
Name Type Description
mapLayer MapLayer 要检查的图层的ID。
Returns:
如果集合包含该图层,则为true,否则为false。
Type
Boolean

destroy()

See:
  • MapLayerCollection#isDestroyed
销毁此集合中所有图层持有的WebGL资源。一旦对象被销毁,它将不能在使用。
Example
mapLayerCollection = mapLayerCollection && mapLayerCollection.destroy();
Throws:
对象已经被销毁。
Type
Cesium.DeveloperError

getById(id) → {MapLayer}

获取给定ID的图层。
Parameters:
Name Type Description
id String 要获取的图层的ID。
Returns:
指定ID的图层,若不存在或ID未定义,则为false。
Type
MapLayer

lower(mapLayer)

将图层在集合中的位置下降一位。
Parameters:
Name Type Description
mapLayer MapLayer 需要移动的图层。
Throws:
  • 图层不在此集合中。
    Type
    Cesium.DeveloperError
  • 该对象已经被销毁,即,调用了destroy()。
    Type
    Cesium.DeveloperError

lowerToBottom(mapLayer)

将图层下降到集合底部。
Parameters:
Name Type Description
mapLayer MapLayer 需要移动的图层。
Throws:
  • 图层不在此集合中。
    Type
    Cesium.DeveloperError
  • 该对象已经被销毁,即,调用了destroy()。
    Type
    Cesium.DeveloperError

raise(mapLayer)

将图层在集合中的位置上升一位。
Parameters:
Name Type Description
mapLayer MapLayer 需要移动的图层。
Throws:
  • 图层不在此集合中。
    Type
    Cesium.DeveloperError
  • 该对象已经被销毁,即,调用了destroy()。
    Type
    Cesium.DeveloperError

raiseToTop(mapLayer)

将图层上升到集合顶部。
Parameters:
Name Type Description
mapLayer MapLayer 需要移动的图层。
Throws:
  • 图层不在此集合中。
    Type
    Cesium.DeveloperError
  • 该对象已经被销毁,即,调用了destroy()。
    Type
    Cesium.DeveloperError

remove(mapLayer, destroyopt) → {Boolean}

如果集合中存在指定的图层,则将它从集合中移除。
Parameters:
Name Type Attributes Default Description
mapLayer MapLayer 将要被移除的图层。
destroy Boolean <optional>
true 是否将移除的图层销毁。
Returns:
是否移除成功。
Type
Boolean

removeAll(destroyopt)

移除图层集合中的所有图层。
Parameters:
Name Type Attributes Default Description
destroy Boolean <optional>
true 是否将移除的图层销毁。

removeById(id, destroyopt) → {Boolean}

如果集合中存在指定ID的图层,则将它从集合中移除。
Parameters:
Name Type Attributes Default Description
id String 将要被移除的图层的ID。
destroy Boolean <optional>
true 是否将移除的图层销毁。
Returns:
是否移除成功。
Type
Boolean