Feat layer legend (#954)

* feat: add cluster demo

* fix(baselayer): 聚合图共用source 时数据不更新问题

layer  增加cluster zoom 标识符'

* fix(source): lint error

* fix: 聚合图缩放等级范围设置

* fix: demo

* fix: demo lint

* fix(layer): getlengenditem
This commit is contained in:
@thinkinggis 2022-02-08 18:02:13 +08:00 committed by GitHub
parent c92a6af563
commit 652acf58ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -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<ChildLayerStyleOptions = {}> 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<ChildLayerStyleOptions = {}> 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<ChildLayerStyleOptions = {}> 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 [];