Skip to content

fix(google-maps): don't crash on a zero-width vector map - #10848

Open
Juice-de-Orange wants to merge 1 commit into
visgl:masterfrom
Juice-de-Orange:fix/google-maps-zero-width
Open

Juice-de-Orange wants to merge 1 commit into
visgl:masterfrom
Juice-de-Orange:fix/google-maps-zero-width

Conversation

@Juice-de-Orange

@Juice-de-Orange Juice-de-Orange commented Oct 11, 2026 •

Copy link
Copy Markdown

Closes #10596

Change List

  • getViewPropsFromCoordinateTransformer: require positive width and height for aspect
  • Unit test for a zero-width vector map

Fix and test are from @kaisermann's report (co-author on the commit). Verified with yarn vitest run --project=headless test/modules/google-maps/: the new test fails on master with the TypeError from the issue and passes with the fix. A temporary test running the 800x600 → 800x0 → 0x0 → 0x600 → 800x600 sequence from the issue no longer throws at 0x600.


Note

Low Risk
Single-line guard in vector-map view projection math plus a regression test; no auth, data, or API surface changes.

Overview
Fixes crashes when a vector Google Map is drawn at zero width (e.g. during resize) by hardening camera/projection setup in getViewPropsFromCoordinateTransformer.

Aspect ratio now uses width / height only when both dimensions are positive; otherwise it falls back to 1. The previous check only guarded on height, so a zero-width map with non-zero height could still produce an invalid aspect and throw during draw.

Adds a headless test that mounts GoogleMapsOverlay on a 0×600 vector map and asserts map.draw() does not throw.

Reviewed by Cursor Bugbot for commit ccb5b3f. Bugbot is set up for automated code reviews on this repo. Configure here.

getViewPropsFromCoordinateTransformer only guarded against a zero
height, so a vector map that briefly reports a width of 0 produced
aspect 0 and a non-invertible projection matrix, and the next draw
threw "Cannot read properties of null (reading '0')".

Fall back to aspect 1 unless both dimensions are positive.

Closes visgl#10596

Co-authored-by: Christian Kaisermann <12702016+kaisermann@users.noreply.github.com>
@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Prevents a zero-width Google vector map from producing a zero projection ratio.

  • Zero-width vector maps draw without throwing.

Reviews (1) · Last reviewed commit: "fix(google-maps): don't crash on a zero-..." · Reviewed by Greptile

This branch has not been deployed

No deployments
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.

[Bug] GoogleMapsOverlay crashes when a vector map is temporarily zero-width

1 participant