From 652acf58ec8d35a89b5af4c36c9530a4fd683686 Mon Sep 17 00:00:00 2001 From: "@thinkinggis" Date: Tue, 8 Feb 2022 18:02:13 +0800 Subject: [PATCH] Feat layer legend (#954) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: add cluster demo * fix(baselayer): 聚合图共用source 时数据不更新问题 layer 增加cluster zoom 标识符' * fix(source): lint error * fix: 聚合图缩放等级范围设置 * fix: demo * fix: demo lint * fix(layer): getlengenditem --- packages/layers/src/core/BaseLayer.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/layers/src/core/BaseLayer.ts b/packages/layers/src/core/BaseLayer.ts index 5b92eaad16..5017d5651b 100644 --- a/packages/layers/src/core/BaseLayer.ts +++ b/packages/layers/src/core/BaseLayer.ts @@ -52,7 +52,6 @@ import { normalizePasses } from '../plugins/MultiPassRendererPlugin'; import { BlendTypes } from '../utils/blend'; import { handleStyleDataMapping } from '../utils/dataMappingStyle'; import { updateShape } from '../utils/updateShape'; -import baseLayerSchema from './schema'; /** * 分配 layer id */ @@ -895,6 +894,7 @@ export default class BaseLayer extends EventEmitter const scale = this.styleAttributeService.getLayerAttributeScale(name); if (scale) { if (scale.ticks) { + // 连续分段类型 const items = scale.ticks().map((item: any) => { return { value: item, @@ -903,6 +903,7 @@ export default class BaseLayer extends EventEmitter }); return items; } else if (scale.invertExtent) { + // 连续类型 const items = scale.range().map((item: any) => { return { value: scale.invertExtent(item), @@ -910,6 +911,16 @@ export default class BaseLayer extends EventEmitter }; }); return items; + } else if (scale?.domain) { + // 枚举类型 + const items = scale.domain().map((item: string | number) => { + return { + // @ts-ignore + value: item || '无', + color: scale(item), + }; + }); + return items; } } else { return [];