Skip to content

Fit all markers into the initial view, fix dark mode map labels - #403

Merged
skerbis merged 1 commit into
mainfrom
fix/map-initial-view-dark-labels
Sep 23, 2026
Merged

skerbis merged 1 commit into
mainfrom
fix/map-initial-view-dark-labels

Conversation

@skerbis

@skerbis skerbis commented Sep 23, 2026

Copy link
Copy Markdown
Member

Problem

Depending on the viewport, parts of the map were cut off in the initial view. The map forced minZoom: 2 and fixed maxBounds, so MapLibre zoomed in further than fitBounds wanted. On anything narrower than ~1920px the markers at the edges (US west coast, Australia) were outside the view; a phone only showed longitudes −18…48.

In dark mode the map labels looked like outlined text: the theme rules for labels never applied because the property/type check expected symbol-*, while label paint properties are text-* / icon-*. The Liberty default (dark text, white halo) stayed active.

Changes

  • Drop maxBounds: MapLibre already keeps the single world (renderWorldCopies: false) inside the viewport.
  • Derive minZoom from the viewport width (full world width fits, max 2), updated on resize. Large screens keep the previous look without empty margins.
  • Smaller fit padding on small screens (60px top/bottom for controls and banner, 20px left/right), also used for the cluster zoom.
  • Map container gets the theme's water color as background, so the area outside the world at low zoom is not grey/white.
  • Theme rules now apply text-* / icon-* properties to symbol layers. Labels are plain light text with a subtle dark halo in dark mode; the intended light mode label colors apply now as well.

Result

Checked headless in Chromium (181 markers, hidden markers in the initial view):

Viewport before after
1024×768 … 3440×1440 0–2 0
375×667 (phone portrait) 4 2
768×1024 (tablet portrait) 2 2

In portrait, MapLibre always fills the viewport height with the world. The markers span 274° of longitude, so the two outermost ones cannot fit there; the rest is centered.

Initial view, desktop 1280×720

initial view desktop

Initial view, phone 375×667

initial view phone

Dark mode labels

dark mode labels

Initial view, desktop dark mode

initial view desktop dark

🤖 Generated with Claude Code

The map forced minZoom 2 and maxBounds, so on most viewports MapLibre
zoomed in further than fitBounds wanted and markers at the edges (US west
coast, Australia) were cut off. Drop maxBounds (MapLibre already keeps the
single world inside the viewport), derive minZoom from the viewport width
(full world width, max 2) and use smaller fit padding on small screens.
The map container gets the theme's water color so the area outside the
world does not show up grey/white at low zoom levels.

Theme rules for labels never applied: the property/type check expected
"symbol-" but label paint properties are "text-*"/"icon-*". Dark mode kept
the default dark text with white halo, which looked like outlined text.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@skerbis
skerbis merged commit b0621b4 into main Sep 23, 2026
1 check passed
@skerbis
skerbis deleted the fix/map-initial-view-dark-labels branch September 23, 2026 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant