Skip to content

fix(google-maps): Robust DOM positioning when interleaved: false#9992

Open
felixpalmer wants to merge 24 commits intomasterfrom
felix/gmaps-non-interleaved
Open

fix(google-maps): Robust DOM positioning when interleaved: false#9992
felixpalmer wants to merge 24 commits intomasterfrom
felix/gmaps-non-interleaved

Conversation

@felixpalmer
Copy link
Collaborator

@felixpalmer felixpalmer commented Feb 9, 2026

Replaces #9985 @neil-morrison44 @chrisgervang

Background

The Google maps library has a number of rendering modes, which can be decided at runtime. At a high level we have:

  • RASTER old code path, uses PNG images as tiles
  • VECTOR newer code, rendering using WebGL and vector data

In order to integrate the deck.gl canvas we need to synchronize with the view state of the Google Map. Two classes are provided for this: google.maps.OverlayView and google.maps.WebGLOverlayView.

For the RASTER case, we have no choice, we must use OverlayView as there is no WebGL context. Conceptually this integration path is simpler as we have a clear DOM element to attach to: overlay.getPanes()?.overlayLayer

For the VECTOR case there is no DOM element, as we instead receive a WebGLContext to draw into.

The complexity comes when we want to support VECTOR with interleaved=false as the WebGLOverlayView does not give use a DOM point to mount to. Currently we just attach to the root element, but this causes issues as the deck.gl canvas is drawn on top of the Google controls.

In the interleaved=false case it seems natural to use the google.maps.OverlayView instead of the google.maps.WebGLOverlayView as we don't need access to the WebGL canvas and instead we want to cleanly add a DOM element (the deck.gl app) to the Google Maps library.

The problem is that google.maps.OverlayView.draw() is limited compared to google.maps.WebGLOverlayView.onDraw(). Specifically google.maps.WebGLOverlayView.onDraw() provides a transformer object which lets deck.gl exactly reconstruct the view state, and it even works during animations/transitions. There is no such API with google.maps.OverlayView.draw, which leads to a glitchy integration (see the long list of commits in this PR for details)

As such for the non-interleaved case, this PR both:

  • Creates an OverlayView in order to position the non-interleaved canvas
  • Creates a WebGLOverlayView in order to obtain transformer object to give correct camera tracking

Change List

  • Create both OverlayView & WebGLOverlayView in non-interleaved case
  • Update callbacks used by overlays
  • Refactor to split code into _createOverlayVector and _createOverlayRaster
  • Fix useDevicePixels default behavior in non-interleaved mode

@felixpalmer felixpalmer changed the title fix(google-maps): Robust D fix(google-maps): Robust DOM positioning when interleaved: false Feb 9, 2026
@coveralls
Copy link

Coverage Status

coverage: 91.091%. remained the same
when pulling 57bdf2a on felix/gmaps-non-interleaved
into b830b0e on master.

...props,
useDevicePixels: props.interleaved ? true : props.useDevicePixels,
// Default to true for high-DPI displays, but allow user override
useDevicePixels: props.useDevicePixels ?? true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice

@chrisgervang
Copy link
Collaborator

I'm unfamiliar with this Google view API. Are there any noticeable performance or billing implications that come with adding two views?

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.

3 participants

Comments