10bestdesign / jqvmap

jQuery Vector Map Library
https://www.10bestdesign.com/jqvmap/
Other
1.82k stars 681 forks source link

Destroy Map? #360

Open DaveZMB opened 3 years ago

DaveZMB commented 3 years ago

Issue #12 asked for the ability to destroy a map dynamically and was marked "won't fix".

But your map creates a jQuery(window).resize event listener every time the map is switched and it can't be removed without removing all query resize event listeners. https://github.com/10bestdesign/jqvmap/blob/master/src/JQVMap.js#L31

I'm using your map (thank you!) to allow users to switch between maps by clicking on some buttons on my page, and things start to slow down to a crawl after switching the map a few times.

As far as I can tell that resize event listener is the only thing that isn't getting properly destroyed when you replace the map container so it'd be really nice to either make that anonymous function call a named function so we can stop it or to have an actual destroy function that just cleans everything up.