Gradient line transition locations shifted #5443
-
maplibre-gl-js version: 5.1.0 browser: Chrome, Safari IssueI am trying to show the path a user takes color-coded based on speed. To achieve this I am using line gradient using data-driven style. ![]() ![]() The first image is the gradient line, and the second is the points. If you see the bottom part of the map, you will see that the green intervals are not aligned in both the images. I am not sure if this is an issue due to floating point accuracy. CodeGeoJSON File: https://gist.github.com/shrijitsingh99/0c11103b85bace16d0a2492f273a5cd7 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I didn't debug the code, but aren't you assuming the distance between every two points is identical? It calculates the length of the route first (in meters) and then calculates the slopes according to the relative place in the route's distance. |
Beta Was this translation helpful? Give feedback.
I didn't debug the code, but aren't you assuming the distance between every two points is identical?
I think this might cause the shift you are seeing.
Here's the code I'm using to present slope on my routes:
https://github.com/IsraelHikingMap/Site/blob/de911cb386f7279cb2c489b84602440470768da8/IsraelHiking.Web/src/application/components/route-statistics.component.ts#L980
It calculates the length of the route first (in meters) and then calculates the slopes according to the relative place in the route's distance.