RandomThemeSource Class

RandomThemeSource(name, options)

随机专题图图层源。

Fx构造函数

# new RandomThemeSource(name, options)

参数:
名称 类型 属性 默认值 描述
name string

名称

options Object

参数。

map ol.Map

当前map对象。

id string <optional>

专题图层 ID。

opacity number <optional>
1

图层透明度。

projection ol.proj.Projection <optional>

投影信息。

ratio number <optional>
1.5

视图比,1 表示画布是地图视口的大小,2 表示地图视口的宽度和高度的两倍,依此类推。必须是 1 或更高。

resolutions Array <optional>

分辨率数组。

state ol.source.State <optional>

资源状态。

style Object <optional>

专题图样式。

isHoverAble boolean <optional>
false

是否开启 hover 事件。

highlightStyle Object <optional>

开启 hover 事件后,触发的样式风格。

查看源代码 openlayers/theme/RandomThemeSource.js, line 7

继承关系

方法

# addFeatures(features)

添加要素。

参数:
名称 类型 描述
features Object

要素对象。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 62

# clear()

清除的内容包括数据(features)、专题要素、缓存。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 230

# destroy()

释放资源,将引用资源的属性置空。

Overrides:

查看源代码 openlayers/theme/RandomThemeSource.js, line 33

# destroyFeatures(features)

销毁某个要素。

参数:
名称 类型 描述
features Zondy.Feature.Vector

将被销毁的要素。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 126

# fire(type, event)

添加专题要素事件监听。

参数:
名称 类型 描述
type string

事件类型。

event string

事件名称。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 342

# getCacheCount() → {number}

获取当前缓存数量。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 241

返回当前缓存数量。

number

# getFeatureBy(property, value) → {Zondy.Feature.Vector}

在专题图的要素数组 features 里面遍历每一个 feature,当 feature[property] === value 时, 返回此 feature(并且只返回第一个)。

参数:
名称 类型 描述
property string

feature 的某个属性名称。

value string

property 所对应的值。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 265

第一个匹配属性和值的矢量要素。

Zondy.Feature.Vector

# getFeatureById(featureId) → {Zondy.Feature.Vector}

通过给定一个 ID,返回对应的矢量要素。

参数:
名称 类型 描述
featureId string

矢量要素的属性 ID。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 285

对应 ID 的 feature,如果不存在则返回 null。

Zondy.Feature.Vector

# getFeatures() → {Zondy.Feature.Vector}

查看当前图层中的有效数据。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 250

用户加入图层的有效数据。

Zondy.Feature.Vector

# getFeaturesByAttribute(attrName, attrValue) → {Array.<Zondy.Feature.Vector>}

通过给定一个属性的 key 值和 value 值,返回所有匹配的要素数组。

参数:
名称 类型 描述
attrName string

属性的 key。

attrValue string

矢量要素的属性 ID。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 295

一个匹配的 feature 数组。

Array.<Zondy.Feature.Vector>

# getLocalXY(coordinate)

获取坐标系统。

参数:
名称 类型 描述
coordinate Object

坐标位置。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 447

# on(event, callback)

添加专题要素事件监听。支持的事件包括: click、mousedown、mousemove、mouseout、mouseover、mouseup。

参数:
名称 类型 描述
event string

事件名称。

callback RequestCallback

事件回调函数。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 324

# redrawThematicFeatures(extent)

重绘所有专题要素。

参数:
名称 类型 描述
extent Object

视图范围数据。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 121

# removeAllFeatures()

清除当前图层所有的矢量要素。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 112

# removeFeatures(features)

从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。

参数:
名称 类型 描述
features Zondy.Feature.Vector

要删除的要素对象。

Inherited From:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 102

# rotate(pixelP, rotation, center)

获取某像素坐标点 pixelP 绕中心 center 逆时针旋转 rotation 弧度后的像素点坐标。

参数:
名称 类型 描述
pixelP number

像素坐标点位置。

rotation number

旋转角度。

center number

中心位置。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 474

# scale(pixelP, center, scaleRatio) → {Array.<number>}

获取某像素坐标点 pixelP 相对于中心 center 进行缩放 scaleRatio 倍后的像素点坐标。

参数:
名称 类型 描述
pixelP Object

像素点。

center Object

中心点。

scaleRatio number

缩放倍数。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 487

返回数组形比例

Array.<number>

# setMaxCacheCount(cacheCount)

设置最大缓存条数。

参数:
名称 类型 描述
cacheCount number

缓存总数。

Overrides:

查看源代码 openlayers/theme/GeoFeatureSource.js, line 250

# setOpacity(opacity)

设置图层的不透明度,取值[0-1]之间。

参数:
名称 类型 描述
opacity number

不透明度。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 145

# un(event, callback)

移除专题要素事件监听。

参数:
名称 类型 描述
event string

事件名称。

callback RequestCallback

事件回调函数。

Inherited From:

查看源代码 openlayers/theme/ThemeSource.js, line 409