聚合图

使用

目前只有点数据支持聚类方法

数据聚合主要从数据层数据,因此需要在Source方法配置 cluster 参数

Source

source 文档

配置项

  • cluster boolean 是否聚合
  • clusterOption 聚合配置项

    • radius 聚合半径 number default 40
    • minZoom: 最小聚合缩放等级 number default 0
    • maxZoom: 最大聚合缩放等级 number default 16

数据聚合之后,数据会增加 point_count属性,在可视化渲染时可以根据 point_count进行数据映射。

方法

getClusters(zoom: number)

获取指定缩放等级的聚合数据

  • zoom 缩放等级

getClustersLeaves(id: string)

  1. 根据id获取聚合节点的数据
  • id 聚合数据id
  1. layer.source(pointsData, {
  2. cluster: true,
  3. });
  4. // 设置配置项
  5. layer.source(pointsData, {
  6. cluster: true,
  7. clusterOption: {
  8. radius: 40,
  9. },
  10. });

完整示例

  1. const pointLayer = new PointLayer({})
  2. .source(pointsData, {
  3. cluster: true,
  4. })
  5. .shape('circle')
  6. .scale('point_count', {
  7. type: 'quantile',
  8. })
  9. .size('point_count', [5, 10, 15, 20, 25])
  10. // .size(10)
  11. .color('red')
  12. .style({
  13. opacity: 0.3,
  14. strokeWidth: 1,
  15. });