Skip to content

Fix: add custom mapping field #3850

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/adaptor/geometries/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export type Geometry = {
readonly rawFields?: RawFields;
/** 图形映射规则 */
readonly mapping?: MappingOptions;
/** 自定义映射字段 */
readonly customMappingField?: string;
/** label 映射通道,因为历史原因导致实现略有区别 */
readonly label?: Label;
/** 不同状态的样式 */
Expand Down Expand Up @@ -156,6 +158,7 @@ export function geometry<O extends GeometryOptions>(params: Params<O>): Params<O
label,
state,
customInfo,
customMappingField,
} = options;

// 如果没有 mapping 信息,那么直接返回
Expand All @@ -179,7 +182,7 @@ export function geometry<O extends GeometryOptions>(params: Params<O>): Params<O
colorField ? geometry.color(colorField, color) : geometry.color(color);
} else if (isFunction(color)) {
const { mappingFields, tileMappingField } = getMappingField(options, 'color');
geometry.color(tileMappingField, getMappingFunction(mappingFields, color));
geometry.color(customMappingField || tileMappingField, getMappingFunction(mappingFields, color));
} else {
colorField && geometry.color(colorField, color);
}
Expand Down
Loading