visgl / react-map-gl

React friendly API wrapper around MapboxGL JS
http://visgl.github.io/react-map-gl/
Other
7.78k stars 1.35k forks source link

Pitch causes coordinate offset [Bug] #2005

Open paulnebel opened 1 year ago

paulnebel commented 1 year ago

Description

Setting a value for pitch in V7.0.16 appears to cause a coordinate offset. The images below show a green polygon that contains features. With Pitch set to 0 I can click on said polygon and retrieve the associated features in both V7.0.15 and V7.0.16. However, with Pitch set to anything other than 0 it gets harder to retrieve the features in V7.0.16 as the pitch increases. Beyond a Pitch of 20 or so, I can't retrieve the features at all by clicking on the polygon in V7.0.16 (whereas clicking on the polygon retrieves features at any Pitch in V7.0.15). This issue doesn't occur if the pitch is set as an initial value, but it does occur if you 'flyTo' the polygon from elsewhere in the map.

The issue is best illustrated by the following animated GIFs. The first GIF is V7.0.15, and pitching the image results in the polygon remaining in the centre of the map. However, in the V7.0.16 version we can see the polygon shifting down from the centre of the map as the pitch increases. It seems that the pitch centre is set above ground level, and this appears to be causing a mis-match between screen coordinates and lat/lng.

NOTE: The ONLY difference between the following images is the version of ReactMapGL being use.

V7.0.15 react-map-gl-7 0 15

V7.0.16 react-map-gl-7 0 16

Expected Behavior

Set Pitch = 0 and click on green polygon: Features are returned by map with V7.0.15 & V7.0.16

Set Pitch = 70 and click on green polygon: Features are returned by map with V7.0.15 but FEATURES ARE NOT RETURNED by map in V7.0.16

Steps to Reproduce

The only difference between the working code and the broken code are the version of ReactMapGL in package.json. It works with 7.0.15, it does not work with v7.0.16

Environment

Logs

No response

Pessimistress commented 1 year ago

Can you create a CodeSandbox that reproduces your issue?

kamranayub commented 1 year ago

I am also noticing that the reported lnglat value on click when using pitch + globe + bearing is off, which feels related to this.