Skip to content

refactor: Replace line page's map implementation with MaplibreX - #3627

Open
joshlarson wants to merge 27 commits into
mainfrom
jdl/refactor/use-maplibrex
Open

joshlarson wants to merge 27 commits into
mainfrom
jdl/refactor/use-maplibrex

Conversation

@joshlarson

@joshlarson joshlarson commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

Asana Ticket: 💈🗺️🛠️ Investigate replacing custom map component implementation with MapLibreX

Implementation

Note

🤖 I used Copilot to generate almost all of this PR, with a decent amount of back and forth. I have looked over and vetted all of the code.

You may find it easier to review this PR commit-by-commit, since each commit accomplishes an isolated bit of functionality and/or fixes a bug. Almost but not quite all of the commits were AI-generated - the first two were just me fiddling with dependencies - the ones with robot in the prefix were Copilot.

I reviewed each diff before committing it.

Screenshots

Things look pretty much the same. Here's a screenshot demonstrating that fact.
Screenshot 2026-11-02 at 11 20 47 AM

How to test

Visit a new line diagram page (1, 39, 66, Red Line) and observe the following subtle changes:

  • When you click to open a vehicle popup, it stays open, even when vehicles move
  • The line shape and stop and vehicle markers no longer flicker.

Everything else should be the same!

Note

One feature that is intentionally preserved is that the map zoom/center resets when you change the variant. That's an intentional design decision, since the route shape can vary pretty dramatically between variants, and we don't want the shape to just disappear if you change the variant (if the newly-selected one is off-screen).

joshlarson and others added 22 commits October 19, 2026 14:03
Map the maplibrex import to a minimal local declaration so tsc doesn't compile the dependency's TypeScript sources.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve imports from maplibrex's sources against assets/node_modules, add the deck.gl type packages it needs, and drop the hand-written maplibrex shim.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@joshlarson
joshlarson marked this pull request as ready for review November 4, 2026 19:30
@joshlarson
joshlarson requested a review from a team as a code owner November 4, 2026 19:30
@joshlarson
joshlarson requested a review from lvachon1 November 4, 2026 19:30
<%!-- Receives the "fit-bounds" event pushed when the direction or variant changes --%>
<div id="new-map-fit" phx-hook="FitBounds" />

<MaplibreX.Components.geojson_layer

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.

Is there a reason one is a geojson_layer with type=line and one is a line_layer? They seem to take the same params and do the same thing?

@joshlarson joshlarson Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, actually, although I don't know if there's a better way.

The geojson_layer adds the shape data as a "source", which the line_layer can then use. That's why the data isn't being passed into the line_layer again.

Comment thread assets/package.json
"lodash": "^4.17.21",
"maplibre-gl": "4.7.0",
"maplibre-gl": "5.24.0",
"maplibrex": "file:../deps/maplibrex",

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.

This path/file doesn't exist on my machine, and npm install doesn't seem to do it either.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Does running mix deps.get first do it?

@joshlarson joshlarson added the dev-green Deploy to dev-green label Nov 9, 2026
joshlarson and others added 2 commits November 9, 2026 15:03
Replace the mutating updatePopup method with a syncPopup helper that returns a new entry, so the no-param-reassign disable is no longer needed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
joshlarson and others added 2 commits November 12, 2026 16:15
MaplibreX compares the map style by reference, so a style object made every patch call map.setStyle and wipe the route shape layers. Wrap the map hook to skip setStyle when the style is unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@lvachon1 lvachon1 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.

🎉

This branch was successfully deployed

1 active deployment
dev-green — ed000b42 Deployed Nov 12, 2026 by joshlarson via pr / Deploy to dev-green #6356
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dev-green Deploy to dev-green

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants