mirror of
https://github.com/maputnik/editor.git
synced 2026-04-23 01:40:01 +00:00
Color relief support and hillshading improvements. (#1371)
## Launch Checklist This adds support for `relief-color` property so that it will create an elevation expression when the button is pressed. It also adds support for `colorArray` and `numberArray` types so that the user would be able to add the relevant information. Before: <img width="403" height="324" alt="image" src="https://github.com/user-attachments/assets/250abd81-6176-4711-a1ee-d33d443932d7" /> <img width="403" height="324" alt="image" src="https://github.com/user-attachments/assets/6a1bb268-66db-42a1-97fc-33e5a40863b6" /> After: <img width="403" height="324" alt="image" src="https://github.com/user-attachments/assets/8ebaa1ea-4ef9-4aed-abcd-3c8b0057ea76" /> <img width="403" height="324" alt="image" src="https://github.com/user-attachments/assets/e0728c92-85f9-4b86-8635-8877cf257b2f" /> - [x] Briefly describe the changes in this PR. - [x] Include before/after visuals or gifs if this PR includes visual changes. - [x] Write tests for all new functionality. - [x] Add an entry to `CHANGELOG.md` under the `## main` section. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -90,6 +90,18 @@ function getDataType(value: any, fieldSpec={} as any) {
|
||||
else if (fieldSpec.type === "array" && isArrayOfPrimatives(value)) {
|
||||
return "value";
|
||||
}
|
||||
else if (fieldSpec.type === "numberArray" && isArrayOfPrimatives(value)) {
|
||||
return "value";
|
||||
}
|
||||
else if (fieldSpec.type === "colorArray") {
|
||||
return "value";
|
||||
}
|
||||
else if (fieldSpec.type === "padding") {
|
||||
return "value";
|
||||
}
|
||||
else if (fieldSpec.type === "variableAnchorOffsetCollection") {
|
||||
return "value";
|
||||
}
|
||||
else if (isZoomField(value)) {
|
||||
return "zoom_function";
|
||||
}
|
||||
@@ -293,6 +305,20 @@ const FieldFunction: React.FC<FieldFunctionProps> = (props) => {
|
||||
props.onChange(props.fieldName, dataFunc);
|
||||
};
|
||||
|
||||
const makeElevationFunction = () => {
|
||||
const expression = [
|
||||
"interpolate",
|
||||
["linear"],
|
||||
["elevation"],
|
||||
0,
|
||||
"black",
|
||||
2000,
|
||||
"white"
|
||||
];
|
||||
|
||||
props.onChange(props.fieldName, expression);
|
||||
};
|
||||
|
||||
const onMarkEditing = () => {
|
||||
setIsEditing(true);
|
||||
};
|
||||
@@ -364,6 +390,7 @@ const FieldFunction: React.FC<FieldFunctionProps> = (props) => {
|
||||
onZoomClick={makeZoomFunction}
|
||||
onDataClick={makeDataFunction}
|
||||
onExpressionClick={makeExpression}
|
||||
onElevationClick={makeElevationFunction}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user