Replies: 2 comments
-
|
To me this sounds like it could be intended behaviour: the resize-event causes the tile-loader to check for tiles to load, it completes its work (or discovers there is nothing to do) and dispatches the idle event once there is nothing more to do. But you could certainly submit this as a question to the Google Maps Issue Tracker as well: https://issuetracker.google.com/issues?q=status:open%20componentid:188853&s=created_time:desc I think in your situation I would recommend manually debouncing this or suspending loader logic until after the window resize ends. |
Beta Was this translation helpful? Give feedback.
-
|
This is expected behavior from the Google Maps API perspective, but there are several patterns you can use to handle this effectively: Root CauseThe Recommended Solutions1. Debounce with ResizeObserver (Most Reliable)Use a ResizeObserver to track when the map container stops resizing, then allow onIdle to execute:
2. Track Window Resize EventsListen to window resize and suppress onIdle temporarily:
3. Use useCallback/useMemo for StabilizationIf your onIdle callback depends on frequently-changing props, memoize it to reduce unnecessary re-evaluations and re-triggers. Why This MattersThe resize and idle events don't have a direct causation relationship you can suppress—the idle event genuinely fires because the map completes its internal repositioning. Debouncing ensures the resize operation finishes before your handler executes. Performance Tips
The maintainer's suggestion is correct—debouncing is the right architectural pattern for this scenario. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using onIdle to refetch map data. It works great! Except when resizing the browser window. As the user drags the window to change size onIdle constantly fires. There is no idle period where it will wait for the resizing to stop.
What is the typical approach used to address this? Manually debounce/timeout the handler? Or is this a bug with idle on the google side of things?
Beta Was this translation helpful? Give feedback.
All reactions