Skip to content

fix(google-maps): align raster overlay under CSS scale transforms - #10843

Open
chrisgervang wants to merge 4 commits into
masterfrom
chr/google-maps-css-transform
Open

chrisgervang wants to merge 4 commits into
masterfrom
chr/google-maps-css-transform

Conversation

@chrisgervang

@chrisgervang chrisgervang commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #10587

Background

With a CSS scale() transform on the map or an ancestor, Google Maps reports container pixels and event.pixel in rendered units, while GoogleMapsOverlay positions its canvas in layout units. On raster maps the deck canvas is shifted, which clips layers, and on raster and vector maps hover and click pick the wrong object.

Change List

  • getViewPropsFromOverlay: measure the pane origin in layout pixels
  • pixelToLngLat: convert through fromDivPixelToLatLng
  • getEventPixel: scale event.pixel back to layout pixels
  • Mock projection: offset container pixels the way Google does
  • Unit tests for raster maps at scale 1 and 0.5
  • Documentation: rotate and skew transforms are not supported

Verified in examples/basemap-browser with a transform on <body>; the scale 0.5 unit test fails without the fix.

Situation Before After
Raster, scale(0.5): layers end at the shifted canvas edge
Raster, scale(0.75, 0.5)
Raster, scale(0.5), pointer on Schiphol (red ring)
Vector overlaid, scale(0.5), pointer on Schiphol (red ring)

Note

Medium Risk
Touches core overlay view-state and input coordinate math for all raster Google Maps integrations; limited to transform edge cases but incorrect math would break alignment or picking broadly.

Overview
Fixes misaligned deck canvases and wrong hover/click picking when the Google Map (or a parent) uses a CSS scale() transform. Google reports container pixels and event.pixel in rendered units while the overlay positions the canvas in layout pixels.

getViewPropsFromOverlay now derives canvas offsets via getDivOrigin (pane origin in layout space, corrected with getContainerPixelScale from getBoundingClientRect vs offsetWidth/Height). pixelToLngLat maps through div pixels (fromDivPixelToLatLng), and getEventPixel divides mouse pixels by the scale so Deck sees layout coordinates.

Tests add raster overlay checks at cssScale 1 and 0.5; the mock Maps API models div vs container pixel offsets like the real API. Docs note scale transforms are supported; rotate/skew on the map or ancestors remain unsupported.

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

Google Maps reports container pixels and mouse event pixels in rendered
units, while the overlay is positioned in CSS layout units. Measure the
overlay pane origin in layout units, convert positions through div
pixels, and scale event pixels back to layout units.
@chrisgervang chrisgervang added this to the v9.4 patch releases milestone Oct 10, 2026
@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found.

Summary

Fixes overlay alignment and pointer coordinates when a Google Map or its ancestor uses CSS scaling.

  • GoogleMapsOverlay keeps scaled maps aligned and picks the object under the pointer.

Both previous findings are addressed. No new actionable issues were found. Tests were inspected, not run.

Reviews (2) · Last reviewed commit: "docs(google-maps): announce CSS scale su..." · Reviewed by Greptile

@coveralls

coveralls commented Oct 10, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.204% (+0.06%) from 84.148% — chr/google-maps-css-transform into master

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I reviewed the coordinate-space changes. Before approval, please add regression coverage for the two paths this diff changes but the current raster/uniform-scale case does not exercise: vector-map picking, and independent non-uniform x/y CSS scales. Also move the scale-support announcement into docs/whats-new.md and leave the unsupported rotate/skew note in this API page. These are focused follow-ups, but without the tests the event-pixel and axis-specific scale conversions remain unverified.

Runs the CSS transform case on raster and vector maps, at scale 1, 0.5 and
the non-uniform scale(0.75, 0.5). The mock map accepts separate x/y scales.
Without the event pixel conversion the vector cases fail; with one scale
for both axes the non-uniform cases fail.
This was referenced Oct 26, 2026
@ibgreen ibgreen added the bug label Nov 21, 2026
@chrisgervang
chrisgervang requested a review from ibgreen November 21, 2026 16:24

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

The coordinate conversions look correct. The new tests check the event pixel that goes to picking (offsetCenter) on raster and vector maps, with uniform and non-uniform scales. They do not check a pick result. The commits 94a5f70 and ba8faa4 make the changes that ibgreen asked for.

Edited after a second check: the tests check the picking pixel, not a pick result.

@chrisgervang chrisgervang mentioned this pull request Nov 24, 2026
29 tasks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Canvas size and positioning misaligned on Google Maps (raster type) with CSS transform

4 participants