Skip to content

front: upgrade maplibre-gl to v6 - #18188

Open
emersion wants to merge 4 commits into
devfrom
emr/maplibre-gl-v6
Open

front: upgrade maplibre-gl to v6#18188
emersion wants to merge 4 commits into
devfrom
emr/maplibre-gl-v6

Conversation

@emersion

Copy link
Copy Markdown
Member

@emersion
emersion requested review from DucNg and kmer2016 August 19, 2026 08:10
@emersion
emersion requested a review from a team as a code owner August 19, 2026 08:10
@emersion emersion moved this to Awaiting merge in Board PI 21 Aug 19, 2026
@emersion emersion self-assigned this Aug 19, 2026
@github-actions github-actions Bot added area:front Work on Standard OSRD Interface modules area:ui Work on UI labels Aug 19, 2026

@hhirtz hhirtz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested.

@DucNg DucNg left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested

@kmer2016 kmer2016 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the branch locally, two things:

  1. IncompatibleConstraints crashes 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)
  1. Storybook maps are blank. Shouldn't we add setWorkerUrl in ui too?

Comment on lines +4 to +8

setWorkerUrl(workerUrl);

const protocol = new Protocol();
addProtocol('pmtiles', protocol.tile);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not we add this in ui too? The Storybook maps look broken, they're all white

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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>
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>
@emersion

emersion commented Sep 7, 2026

Copy link
Copy Markdown
Member Author

IncompatibleConstraints crashes 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

Indeed, good catch! A note warns about this in the migration guide's "Nested GeoJSON properties" section. Fixed!

Storybook maps are blank. Shouldn't we add setWorkerUrl in ui too?

Indeed! Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:front Work on Standard OSRD Interface modules area:ui Work on UI

Projects

Status: Awaiting merge

Development

Successfully merging this pull request may close these issues.

4 participants