Repository navigation
fix(google-maps): align raster overlay under CSS scale transforms - #10843
chrisgervang wants to merge 4 commits into
Conversation
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.
[Medium impact] The PR appears safe to merge; both previous findings are addressed and no new blocking issue was found. SummaryFixes overlay alignment and pointer coordinates when a Google Map or its ancestor uses CSS scaling.
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 |
ibgreen
left a comment
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Closes #10587
Background
With a CSS
scale()transform on the map or an ancestor, Google Maps reports container pixels andevent.pixelin rendered units, whileGoogleMapsOverlaypositions 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 pixelspixelToLngLat: convert throughfromDivPixelToLatLnggetEventPixel: scaleevent.pixelback to layout pixelsVerified in
examples/basemap-browserwith a transform on<body>; the scale 0.5 unit test fails without the fix.scale(0.5): layers end at the shifted canvas edgescale(0.75, 0.5)scale(0.5), pointer on Schiphol (red ring)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 andevent.pixelin rendered units while the overlay positions the canvas in layout pixels.getViewPropsFromOverlaynow derives canvas offsets viagetDivOrigin(pane origin in layout space, corrected withgetContainerPixelScalefromgetBoundingClientRectvsoffsetWidth/Height).pixelToLngLatmaps through div pixels (fromDivPixelToLatLng), andgetEventPixeldivides mouse pixels by the scale so Deck sees layout coordinates.Tests add raster overlay checks at
cssScale1 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.