Line Gradient based on Property Data or Feature Status
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hi there. I left the point I was not sure about blank so I can fill them as we go.
Motivation
I'm trying to draw a gradient map (heatmap with data based colors) and a line gradient based on property data or some data, set externally via javascript (feature status).
So basically I want to draw this: https://maplibre.org/maplibre-gl-js-docs/example/line-gradient/
Based on a number for every "waypoint" of the line and draw a gradient between.
The mapping would work like in the circle color:
'circle-color': [
'interpolate',
['linear'],
['get', 'averageDelay'],
-2000,
'rgba(0,73,194,0.85)',
-300,
'rgba(63,133,215,0.85)',
0,
'rgba(24,201,145,0.85)',
500,
'rgba(220,95,20,0.85)',
2000,
'rgb(178,24,43)'
],
Design Alternatives
Design
Mock-Up
Concepts
Implementation
Currently I see that https://github.com/maplibre/maplibre-gl-js/blob/3839bd0700ffdaba059dd5d0e7d67069a337e25f/src/util/color_ramp.ts#L20
renderColorRamp is taking the data via evaluationGlobals[params.evaluationKey] = progress;
I wonder if it is possible to pass the feature properties to renderColorRamp and render the gradient based on this.
I could eventually get the distances between the lineString coordinates and then calculate the progress (percent of line) and have a map of progress to number entries in the properties.
Or I have a map or coordinates to numbers and renderColorRamp is figuring out where which color point should be.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/util/color_ramp.ts and the renderColorRamp implementation referenced in the issue. Investigate how evaluationGlobals currently supplies progress, and determine how feature properties or externally supplied status values could reach the gradient calculation. Done should include an agreed design and a working line gradient based on per-waypoint data, but the issue does not name tests or a validation path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- data-visualization, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100