arcgis 聚合图层EsriClusterLayer (二)
通过我们构建的EsriClusterLayer 还没有完全做完 那个只是封装了一个Featurelayer而已
首页options 我们定义有什么呢
- fields: featurelayer 的fileds 集合 等同于 FeatureLayer的fields
- geometryType: geometry的类型 等同于FeatureLayer的geometryType
- data: graphics 集合等同于 featurelayer的 sources,
- distance: 距离多少聚合 单位为米
- id: 'clusters' id 随意
- resolution: 分辨率
- notClusterScale: 需要在哪个比例尺不再聚合全部显示
- spatialReference: 该图层的坐标参考
监听view的zoom 事件实时去刷新 EsriClusterLayer 如果滚轮滚太快的话会导致多次渲染我们做一个防抖
通过EsriClusterRenderLayer 的调用来使用聚合图层
```javascript
import { esriClusterLayer } from './EsriClusterLayer';
export class EsriClusterRenderLayer{
constructor(viewer, layerInfo){
-
this.map = viewer.map;
-
this.view = viewer;
-
this.layerInfo = layerInfo;
-
this.lastZoom = 0;
-
this.init();
}
async init(){
let view = this.view;
let options = {
fields: this.layerInfo.fields,
geometryType: this.layerInfo.geometryType,
data: this.layerInfo.data,
distance: this.layerInfo.distance,
id: 'clusters',
resolution: view.extent.width / view.width,
notClusterScale: this.layerInfo.notClusterScale,
spatialReference: this.layerInfo.spatialReference,
};
options.fields.push(
{
name: 'clusterId',
alias: 'clusterId',
type: 'double'
}
);
更多消息参考小专栏 https://xiaozhuanlan.com/topic/4072983615