My custom buttom disapear on fullscreen in @react-google-maps/api

Viewed 226

I create a custom button that allows me to do some stuff over the map. I press the fullscreen button and it disappears.

I tried to play with the console and take it forward with z-index and other stuff.

https://codesandbox.io/s/romantic-chihiro-ns1vv?file=/src/LoadMap.jsx

This is my code in codesandbox for the bug.

Please press on the "open in a new window" to get the fullscreen button.

Thanks!

2 Answers

fullscreen mode creates inside it element. You should add your button after it creates, in React you can do it with ReactDOM.createPortal. Here you should add your btn: document.getElementById('your-map-id').getElementsByTagName('div')[0]

Related