1. ClusterLayer
Extends: Layer
1.1. 初始化 new ClusterLayer(options)
聚合图层, datasource聚合
Param | Type | Description |
---|---|---|
options | Object |
包含以下参数的Object对象: |
[options.name] | String |
图层名称; |
[options.show] | Boolean |
是否显示; |
[options.customGroupId] | String |
自定义分组的ID。 |
Example
//通过图层管理类统一创建图层
clusterLayer = layerManager.createLayer(BOSGeo.LayerType.CLUSTER, 'CLUSTER123'); // 创建聚合图层
1.2. 属性
属性名 | Type | Default | Description |
---|---|---|---|
show | Boolean | true | 是否显示图层 |
enabled | Boolean | true | 是否聚合 |
1.3. 方法
1.3.1. clusterLayer.add(options) ⇒ CustomDataSource | undefined
添加Cluster聚合图层数据
Param | Type | Default | Description |
---|---|---|---|
options | Object |
聚合参数配置: |
|
options.positions | Array.<Object> |
包含位置position和属性attribute对象的数组; |
|
[options.entityType] | String |
'billboard' |
实体类型,目前只支持“billboard”; |
[options.show] | Boolean |
true |
是否显示点图标; |
[options.enabled] | Boolean |
true |
是否进行聚合; |
[options.img] | String |
'./resource/images/tools/start.png' |
点的图标; |
[options.opacity] | Number |
1 |
点图标的透明度; |
[options.color] | String |
'#FFFFFF' |
点图标的颜色,十六进制颜色值; |
options.iconColor | String |
聚合图标的颜色,,十六进制颜色值; |
|
[options.size] | Number |
50 |
点图标尺寸; |
[options.displayDistance] | Number |
10000 |
点图标最远显示距离; |
[options.pixelRange] | Number |
80 |
图标聚合的像素范围; |
[options.minimumClusterSize] | Number |
1 |
图标聚合的最小像素; |
[options.name] | String |
图标名称。 |
Example
BOSGeo.Resource.fetchJson({
url: 'https://bosgeo.boswinner.com/geoData/vector/bianpos.js'
}).then(features => {
var pointspositon = [];
for (var p = 0; p < features.length; p++) {
pointspositon.push({
position: [features[p].geometry.x, features[p].geometry.y, 0],
attribute: features[p].attributes
});
}
var clusterObj = clusterLayer.add({
name: '聚类图层1',
type: 'billboard',
positions: pointspositon,
displayDistance: 90000,
show: true,
iconColor: '#da1212',
img: 'Assets/Images/tools/start.png',
pixelRange: 100,
minimumClusterSize: 3
});
setTimeout(() => {
clusterLayer.zoomToLayer();
}, 500);
});
1.3.2. clusterLayer.zoomTo(dataSource)
缩放至指定的DataSource
Kind: instance method of ClusterLayer
Param | Type | Description |
---|---|---|
dataSource | CustomDataSource |
数据源对象 |
1.3.3. clusterLayer.zoomToLayer()
缩放至图层
Kind: instance method of ClusterLayer
1.3.4. clusterLayer.removeAll()
移除该图层的所有点要素
Kind: instance method of ClusterLayer
1.3.5. clusterLayer.destroy()
销毁图层对象