# new ThemeSource(name, option)
参数:
名称 | 类型 | 属性 | 默认值 | 描述 |
---|---|---|---|---|
name |
string | 专题图图层名称。 |
||
option |
Object | 参数。 |
||
map |
ol.Map | 当前 openlayers 的 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> |
资源状态。 |
继承关系
- ol.source.ImageCanvas
方法
# addFeatures(features)
抽象方法,可实例化子类必须实现此方法。向专题图图层中添加数据, 专题图仅接收 Zondy.Feature.Vector 类型数据, feature 将储存于 features 属性中,其存储形式为数组。
参数:
名称 | 类型 | 描述 |
---|---|---|
features |
Object | 待转要素。 |
# getFeatureBy(property, value) → {Zondy.Feature.Vector}
在专题图的要素数组 features 里面遍历每一个 feature,当 feature[property] === value 时, 返回此 feature(并且只返回第一个)。
参数:
名称 | 类型 | 描述 |
---|---|---|
property |
string | feature 的某个属性名称。 |
value |
string | property 所对应的值。 |
第一个匹配属性和值的矢量要素。
# getFeatureById(featureId) → {Zondy.Feature.Vector}
通过给定一个 ID,返回对应的矢量要素。
参数:
名称 | 类型 | 描述 |
---|---|---|
featureId |
string | 矢量要素的属性 ID。 |
对应 ID 的 feature,如果不存在则返回 null。
# getFeaturesByAttribute(attrName, attrValue) → {Array.<Zondy.Feature.Vector>}
通过给定一个属性的 key 值和 value 值,返回所有匹配的要素数组。
参数:
名称 | 类型 | 描述 |
---|---|---|
attrName |
string | 属性的 key。 |
attrValue |
string | 矢量要素的属性 ID。 |
一个匹配的 feature 数组。
# on(event, callback)
添加专题要素事件监听。支持的事件包括: click、mousedown、mousemove、mouseout、mouseover、mouseup。
参数:
名称 | 类型 | 描述 |
---|---|---|
event |
string | 事件名称。 |
callback |
RequestCallback | 事件回调函数。 |
# redrawThematicFeatures(extent)
抽象方法,可实例化子类必须实现此方法。重绘专题要素。
参数:
名称 | 类型 | 描述 |
---|---|---|
extent |
Array | 当前级别下计算出的地图范围。 |
# removeFeatures(features)
从专题图中删除 feature。这个函数删除所有传递进来的矢量要素。 参数中的 features 数组中的每一项,必须是已经添加到当前图层中的 feature, 如果无法确定 feature 数组,则可以调用 removeAllFeatures 来删除所有 feature。 如果要删除的 feature 数组中的元素特别多,推荐使用 removeAllFeatures, 删除所有 feature 后再重新添加。这样效率会更高。
参数:
名称 | 类型 | 描述 |
---|---|---|
features |
Array.<Zondy.Feature.Vector> | 要删除 feature 的数组。 |
# rotate(pixelP, rotation, center)
获取某像素坐标点 pixelP 绕中心 center 逆时针旋转 rotation 弧度后的像素点坐标。
参数:
名称 | 类型 | 描述 |
---|---|---|
pixelP |
number | 像素坐标点位置。 |
rotation |
number | 旋转角度。 |
center |
number | 中心位置。 |
# scale(pixelP, center, scaleRatio) → {Array.<number>}
获取某像素坐标点 pixelP 相对于中心 center 进行缩放 scaleRatio 倍后的像素点坐标。
参数:
名称 | 类型 | 描述 |
---|---|---|
pixelP |
Object | 像素点。 |
center |
Object | 中心点。 |
scaleRatio |
number | 缩放倍数。 |
返回数组形比例