Skip to content

Migrate map basemap to MapLibre GL Leaflet - #53836

Closed
birkskyum wants to merge 2 commits into
home-assistant:devfrom
birkskyum:maplibre-gl-leaflet-v6
Closed

Migrate map basemap to MapLibre GL Leaflet#53836
birkskyum wants to merge 2 commits into
home-assistant:devfrom
birkskyum:maplibre-gl-leaflet-v6

Conversation

@birkskyum

@birkskyum birkskyum commented Aug 27, 2026

Copy link
Copy Markdown

Proposed change

Replace the map's Leaflet raster tile layer with @maplibre/maplibre-gl-leaflet and the OpenFreeMap Liberty vector style.

This is an incremental migration: Leaflet remains responsible for the map API, entity markers, clustering, paths, and drawing controls, while MapLibre GL JS renders the basemap. This limits the scope of the change and provides a path toward a future native MapLibre implementation.

MapLibre GL JS v6 is ESM-only and requires explicit worker handling when bundled. This PR therefore:

  • Adds MapLibre GL JS 6 and the MapLibre GL Leaflet bridge.
  • Uses the OpenFreeMap Liberty vector style.
  • Configures a same-origin MapLibre worker URL.
  • Copies both maplibre-gl-worker.mjs and its required maplibre-gl-shared.mjs sibling into the frontend static assets.
  • Includes the MapLibre stylesheet in the map shadow root.
  • Updates Rspack handling so ESM-only dependencies resolve correctly.
  • Keeps existing Leaflet map behavior and tests intact.

Screenshots

Before: CARTO raster basemap

Screenshot 2026-08-27 at 13 48 18

After: OpenFreeMap Liberty vector basemap

Screenshot 2026-08-27 at 14 53 04 Screenshot 2026-08-27 at 14 53 14

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Validation performed:

  • Map component tests pass.
  • Type checking passes.
  • ESLint, Prettier, and the production dependency license check pass.
  • The modern production frontend build completes successfully.
  • A browser smoke test confirmed that the Liberty style and its vector source load, MapLibre uses WebGL2, the self-hosted worker modules load, attribution is shown, and Leaflet markers remain visible.

Checklist

  • I understand the code I am submitting and can explain how it works.
  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • I have followed the perfect PR recommendations
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

If user exposed functionality or configuration variables are added/changed:

To help with the load of incoming pull requests:

@home-assistant home-assistant Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi @birkskyum

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant
home-assistant Bot marked this pull request as draft August 27, 2026 12:55
@home-assistant

Copy link
Copy Markdown

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@github-actions github-actions Bot added Build Related to building the code Tests: Unit Related to Vitest unit tests labels Aug 27, 2026
@bramkragten

Copy link
Copy Markdown
Member

Duplicate of #53816?

@birkskyum

birkskyum commented Aug 27, 2026

Copy link
Copy Markdown
Author

Yeah, actually! Great work @bramkragten !

@birkskyum birkskyum closed this Aug 27, 2026
@bramkragten

Copy link
Copy Markdown
Member

Thanks for your PR, will take the pieces out that are actually better than mine ;-)

bramkragten added a commit that referenced this pull request Aug 27, 2026
At Leaflet zoom 0 the adapter drives the MapLibre map to -1, below the
range MapLibre is specified for. Measured, no drift was observable there
and the centres stayed in sync, but the adapter's own README recommends a
floor of 1 and nobody views a home automation dashboard from world zoom,
so there is nothing to weigh against staying inside spec.

Spotted in #53836 by @birkskyum, which set this correctly where this
branch did not.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Build Related to building the code cla-signed Tests: Unit Related to Vitest unit tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants