deck.gl icon indicating copy to clipboard operation
deck.gl copied to clipboard

Deck gl layers appearing on 'wrong' copy of world with Google Maps

Open SterlingMcCall opened this issue 7 years ago • 6 comments

Description

When displaying deck.gl layers on a google map, the layer 'disappears' when the center of the visible map crosses the anti-meridian. I say 'disappears' because what is actually happening is the deck.gl layer is prematurely jumping over to the second copy of the world that gets created when you pan too far west.

How it should work: Go to this pure Google maps marker demo and zoom out until you see most of the world, but not so far that you see multiple Australias. As you move the map over to view more to the west, you will see that the Marker stays on the first Australia until it is off screen and then appears on the second Australia only when that Australia moves into the map bounds. If you zoom out to see multiple Australias, the marker will appear on which Australia is closer to the center of the screen, which makes a lot of sense.

Deck.gl jumps to new copies of the globe as soon as that copy of the globe takes up most of the screen. So, if I have a layer with an image on San Francisco and I move the map east to view the next world's copy of San Francisco, I won't see the image until the new globe takes up most of the screen, which does not look good at all.

I know this is hard to convey with text so I made a short video:

DECK_GL_SINGLE_GOOGLE_MAP_BUG

Repro Steps

Place any content on a layer. The effect is most noticeable when zoomed out very far and with elements near the anti-meridian (far east or west).

Environment (please complete the following information):

  • Framework Version: 7.2.3

SterlingMcCall avatar Sep 11 '19 21:09 SterlingMcCall

This is a known problem. We are planning to address it in the next major release; meanwhile there are two ways you can work around this:

  • If you are using a point-like layer (Scatterplot, Icon, Text, Scenegraph etc.) or a line-like layer (Line, Arc) you can try set the wrapLongitude: true prop. This will automatically project a point to the copy of the map so that it's closest to the current viewport center.
  • Otherwise you can manually make a copy of your data by shifting all longitudes +/- 360 degrees. This gives you the most control over where something is rendered.

Pessimistress avatar Sep 11 '19 21:09 Pessimistress

@Pessimistress Thanks. wrapLongitude definitely helped. I also observed that if you zoom out far enough to see the entire world (plus a little of another) that all the layers disappear completely. Is that related to the known issue? Or is that a separate issue? You can observe the disappearing behavior in this demo that I created for issue #3567.

SterlingMcCall avatar Sep 12 '19 16:09 SterlingMcCall

@SterlingMcCall deck.gl does not support Google Map's zoom: 0. It basically implements the shared camera logic between Mapbox and Google Maps, which is up to Google's zoom level 1.

Pessimistress avatar Sep 12 '19 19:09 Pessimistress

@Pessimistress With a wide enough window (or use browser zoom to make it small) I can experience the disappearance at zoom levels 1, 2, 3, and 4.

SterlingMcCall avatar Sep 12 '19 20:09 SterlingMcCall

This is our only show/hide logic: https://github.com/uber/deck.gl/blob/master/modules/google-maps/src/google-maps-overlay.js#L82

(Note that deck.gl's zoom is Google Map's zoom - 1)

Pessimistress avatar Sep 12 '19 21:09 Pessimistress

This will be fixed in 8.1.0. You can test the feature with deck.gl@^8.1.0-alpha.

Pessimistress avatar Mar 01 '20 18:03 Pessimistress