You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Every time new google.maps.Map(... is called on a new DOM element it adds a load of window and global event listeners. When the holding element is removed from the DOM the global events keep the map in memory.
This isn't a problem in traditional web apps, as the events are reset on the next page load, but in an SPA or PWA you get a stack of old maps in memory that are all listening for window resize and keydown events.
There appear to be two approaches to working around this:
Maintain a singleton map/s DOM element that are reset and reused.
Remove all the events on detach.
While the latter is preferred, it doesn't seem possible without digging through the internal implementation of the maps API.
The text was updated successfully, but these errors were encountered:
This is a known issue in the API: https://issuetracker.google.com/issues/35821412 - it's been extant since 2011, so a fix is unlikely.
Every time
new google.maps.Map(...
is called on a new DOM element it adds a load ofwindow
and global event listeners. When the holding element is removed from the DOM the global events keep the map in memory.This isn't a problem in traditional web apps, as the events are reset on the next page load, but in an SPA or PWA you get a stack of old maps in memory that are all listening for window resize and keydown events.
There appear to be two approaches to working around this:
While the latter is preferred, it doesn't seem possible without digging through the internal implementation of the maps API.
The text was updated successfully, but these errors were encountered: