react-map-gl icon indicating copy to clipboard operation
react-map-gl copied to clipboard

[Bug] Adding mapbox-gl styles hides html overlay

Open cherealnice opened this issue 4 years ago • 2 comments

Description

Hi,

I have been working with an HTML overlay and trying to figure out why it wasn't showing up. I finally realized that the issue is triggered when I add in the mapbox-gl styles. I tried both with ES6 import and with stylesheet link, and both cause the issue. Is this a react-map-gl issue?

Expected Behavior

HTML overlays should not disappear when adding mapbox-gl styles.

Steps to Reproduce

NOTE: You need to add a token to TOKEN

Code sandbox: https://codesandbox.io/s/optimistic-pond-56i1xz?file=/src/App.tsx

Notice that when the mapbox-styles are added (they are currently commented out at the top of App.tsx), the HTML overlay disappears.

Environment

Logs

No response

cherealnice avatar May 20 '22 10:05 cherealnice

Remove position: 'absolute' from your overlay content then you can see it's at the top right corner. Controls by default are added to the top right, see addControl.

Set position to 'top-left' if you want it to appear on the top left: https://visgl.github.io/react-map-gl/docs/api-reference/use-control#signature

The bug template is for reporting bugs in the library. Please use discussions if you need help debugging your own application.

Pessimistress avatar May 20 '22 16:05 Pessimistress

Hi @Pessimistress thanks for the response. I had simplified my sandbox to show a basic case where it's breaking, but the goal is to show an element at different places on the map, depending on where the user clicks.

I created this by following the custom-overlay example in this repo, which can be found here. After doing some testing, it seems like it is necessary to create a div control over the full map in order to absolutely position a component inside of it. Also, it's necessary to add pointer-events: all to be able to interact with the rendered element. I updated my sandbox to create a basic version of this, and I just want to make sure I understand this correctly. Thank you.

cherealnice avatar May 23 '22 08:05 cherealnice