Skip to content

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

Open
chrisgervang wants to merge 1 commit into
masterfrom
chr/google-maps-css-transform
Open

chrisgervang wants to merge 1 commit 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

RetriggerConfidence Score: 4/5

[Medium impact] Fixes overlay alignment under CSS scale transforms.

No concrete behavior defect was found, but the release-note requirement must be satisfied before merging.

Findings

  1. P2 Scale support misses release notes ▶
  2. P2 Important scale cases lack tests ▶

Summary

This PR fixes raster canvas placement and shared pointer coordinates under CSS scaling.

  • Google Maps overlays keep canvas and pointer positions aligned under CSS scaling.

Reviews (1) · Last reviewed commit: "fix(google-maps): align raster overlay u..." · Reviewed by Greptile

- Controller
- React integration
- Gesture event callbacks (e.g. `onDrag*`)
- CSS rotate or skew transforms on the map or its ancestors (scale transforms are supported)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Scale support misses release notes

The new limitation bullet also announces scale-transform support. The repository requires newly added support to be documented in docs/whats-new.md instead. Keep the rotate/skew limitation here and move the support announcement to that file. This requirement must be satisfied before merging.

Rule Used: In the deck.gl repository, use Remarks sections only for user-facing, actionable limitations; document newly added support in docs/whats-new.md instead. (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Comment on lines +264 to +265
for (const cssScale of [1, 0.5]) {
test(`GoogleMapsOverlay#raster CSS transform (scale:${cssScale})`, async () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Important scale cases lack tests

The new test covers only raster maps with uniform scaling. But getEventPixel changes vector picking too, and getContainerPixelScale treats the two axes separately. Extend the test and mock to cover vector picking and unequal horizontal and vertical scales. Otherwise, either case could break while these tests still pass.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 83.594% (+0.08%) from 83.517% — chr/google-maps-css-transform into master

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] Canvas size and positioning misaligned on Google Maps (raster type) with CSS transform

2 participants