Force zoom to update
See original GitHub issueHey! great work on this component… but I’m getting a bug that I don’t know how to fix it.
Imagine the scenario…
I start the plugin with 12
zoom. After that I navigate a little bit though the map, change the zoom by interacting with the map.
After a while, I want to add different markers to the component, I recalculate the center position and the default zoom using fitBounds
from google-map-react/utils
. But the zoom returned by fitBounds
is still 12
(and that’s ok).
The problem is that if the zoom is the same as the first one when the component started, it does not goes back to 12. It keeps the last one that I interacted with the map (5 for example).
The map gets centralized again, but the zoom breaks 😦
Am I missing something? or is there a methods that helps me with that?
Thanks!
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (3 by maintainers)
This is expected behavior if you change center or zoom but does not provide onChange handler - it’s like
<input value={val} />
without onChange. Instead of React I just don’t show warning, for most use cases even withoutonChange
all works fine.You need to use control in controllable way to get no strange behavior in all cases.
I see… I’ll handle that.
Thanks @istarkov.