front: upgrade maplibre-gl to v6 - #18188
Conversation
kmer2016
left a comment
There was a problem hiding this comment.
Tested the branch locally, two things:
IncompatibleConstraintscrashes on hover. Import the attached timetable on a small_infra scenario, then open the train in edit mode. it fails with incompatible constraints. Hovering a segment on the map throws on every mousemove:
Uncaught SyntaxError: Unexpected token 'i', "incompatib"... is not valid JSON
at fnMouseMove (IncompatibleConstraints.tsx:101:45)- Storybook maps are blank. Shouldn't we add setWorkerUrl in ui too?
|
|
||
| setWorkerUrl(workerUrl); | ||
|
|
||
| const protocol = new Protocol(); | ||
| addProtocol('pmtiles', protocol.tile); |
There was a problem hiding this comment.
Should not we add this in ui too? The Storybook maps look broken, they're all white
There was a problem hiding this comment.
Hm, it seems like these have been broken for some time because they rely on the defunct osm.osrd.fr tile server. See: https://ui.osrd.fr/?path=/story/warpedmap-sample-maps--path-short
dd9b044 to
2da5306
Compare
2da5306 to
73b7b9d
Compare
7febb69 to
3e65955
Compare
We use Vite for building our stories. Enable client types so that TypeScript properly understands Vite imports: https://vite.dev/guide/features.html#client-types With this change, we can drop our custom '*.svg' module: vite/client already includes it. Signed-off-by: Simon Ser <contact@emersion.fr>
This chunk of code is required for all maps to load, but was hidden in the editor map component. Move it to a common map initialization file, and load that file from index.tsx. Signed-off-by: Simon Ser <contact@emersion.fr>
Add a unified initialization file for Maplibre. Right now it just contains the CSS import, but soon it'll also get a new setWorkerUrl() call, required for maplibre-gl v6. As a bonus, this adds a missing CSS import in the Algorithms story. The CSS file was included by the BaseMap story so the Algorithms happened to get it by chance, but better be explicit. Signed-off-by: Simon Ser <contact@emersion.fr>
3e65955 to
cb35113
Compare
An import needs to be adjusted, and setWorkerUrl() needs to be called. Nested arrays in GeoJSON feature properties are now preserved, so we need to remove JSON.parse() calls from IncompatibleConstraints, as hinted by the migration guide. Migration guide: https://github.com/maplibre/maplibre-gl-js/blob/HEAD/docs/guides/v5-to-v6-migration-guide.md Vite setup guide: https://github.com/maplibre/maplibre-gl-js/blob/1275d68a557f6c9f81a169707a2ce219bcc6dc90/docs/index.md#installation Signed-off-by: Simon Ser <contact@emersion.fr>
cb35113 to
4adbaa2
Compare
Indeed, good catch! A note warns about this in the migration guide's "Nested GeoJSON properties" section. Fixed!
Indeed! Done. |
See individual commits.
Migration guide:
https://github.com/maplibre/maplibre-gl-js/blob/HEAD/docs/guides/v5-to-v6-migration-guide.md
Vite setup guide:
https://github.com/maplibre/maplibre-gl-js/blob/1275d68a557f6c9f81a169707a2ce219bcc6dc90/docs/index.md#installation