visgl / react-map-gl

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

[Bug] When 3D terrain is enabled, the clickable area of a line layer is not aligned its visual representation #2196

Closed dstantwo closed 1 year ago

dstantwo commented 1 year ago

Description

I have a small demo to reproduce this issue where I'm displaying the Half Dome hiking trail as a geojson source/layer on a map with 3d terrain enabled. I've made the layer clickable with the interactiveLayerIds prop.

With react-map-gl, the line layer renders, but the clickable area of the line is not aligned with the visual representation of the layer. You can see in the video below that the cursor turns into a pointer some distance away from the line. 🔗 Here's a code sandbox link to this react-map-gl demo (you'll have to add your own Mapbox token in App.js) https://codesandbox.io/s/react-map-gl-terrain-layer-bug-t5p3vw?file=/src/App.js

642D09F0-7123-4951-AF83-5E5D48376586

For comparison, a nearly identical setup that uses mapbox-gl directly (without using react-map-gl), works as expected so that the clickable area of the line aligns with the visual representation. A8F1E6A3-7C4E-47F6-9AC6-6432AEEA6701 🔗 Here's a code sandbox link to this mapbox-gl only demo (again, you'll have to add your own Mapbox token in App.js) https://codesandbox.io/s/mapbox-gl-js-terrain-layer-working-5f8vm2?file=/src/App.js

Expected Behavior

I would expect the clickable area of a geojson layer to align with the layer's visual representation in react-map-gl as it does in plain mapbox-gl

Steps to Reproduce

Environment

Logs

No response

jonshutt commented 1 year ago

I'm just investigating a similar issue - which is that when you click the map, and add a marker that point, the marker that appears in in a slightly different place. Also, when you add a draggable marker, when you drag it, it doesn't move up and down to track the terrain (it does this when dragging a marker using mapbox without react-map-gl), then when you stop dragging, pan the map, it jumps.

It seems to me, the whatever interprets mouse pointer the position isn't factoring in terrain.

Pessimistress commented 1 year ago

Fixed in 7.1.6

amaclean2 commented 7 months ago

Still the same behavior in 7.1.7. I created a geoJSON point at [e.lngLat.lng, e.lngLat.lat] to represent the cursor location and in steeper terrain it's vastly off the cursor pointer.

VahanLab commented 1 week ago

I confirm this issues still occurs on our side too. Also when moving the map while 3D is activated, markers are randomly jumping from their original positions. This issue is quite critical, issue is not closed

amaclean2 commented 1 week ago

Weirdly, it's not an issue when you use the useEffect implementation given from MapBox. So it's something that's lost in translation from that to React-Map-GL

VahanLab commented 1 week ago

@amaclean2 could you please share the code snippet you mentioned using useEffect? I'd love to have a way to get rid of this bug