New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Canvas width/height don't update when container's width/height are changed #2338
Comments
I was able to workaround this by manually calling |
This is not a bug. v7 follows mapbox-gl's own behavior, which does not monitor the resize of your container. You are supposed to call resize yourself. |
So this kinda falls into this item? (from the Upgrading docs):
Adding this feature can be considered but I'm also fine with the workaround above. Mentioning it in the documentation could also be helpful—spent quite a lot of time debugging and making sure it was not an issue with my implementation.
What explains it fixing itself when the browser window is resized? Is mapbox-gl handling it? |
Yes. mapbox-gl's |
Hey @dlbnco can you elaborate? |
Description
After upgrading to v7, I noticed this behavior in my application which has maps displayed in different dimensions that often change.
Map with initial size
When a map container changes it's width/height, the underlying
canvas
that actually renders the map does not update to follow the change, resulting in a incorrectly sized render.Map with new size and outdated canvas
If the browser window is resized, then the canvas will update as expected.
Map with corrected canvas after browser window resize
Expected Behavior
The underlying
canvas
should follow container dimension changes immediately.Steps to Reproduce
This is reproducible in any of the hosted lib examples, e.g.: https://visgl.github.io/react-map-gl/examples/controls
container padding-top--md padding-bottom--lg
max-width
tounset
— this will increase the element's widthEnvironment
Logs
No response
The text was updated successfully, but these errors were encountered: