3

I am developing an app with phonegap and because of the way it works with mobile framework, where everything / every page is on a single document, I'd like to be able to safely remove a google map from the DOM when I need to display another map for another purpose.

I believe doing something like $("selectorforGmap").empty() is not the best practice.

Please advice.

Thanks

Miles M.
  • 4,089
  • 12
  • 62
  • 108
  • "safely" in which context (avoiding memory leaks)? – Dr.Molle Apr 01 '14 at 11:01
  • yes, as well as making sure no script is still running on the background and no variables / objects are kept in memory – Miles M. Apr 01 '14 at 21:50
  • I'm afraid there is no good solution, see: [Google Maps JS v3 - detached DOM tree - memory leak?](http://stackoverflow.com/questions/21142483/google-maps-js-v3-detached-dom-tree-memory-leak). I think the best you can do is to use use the same Map-instance for all pages – Dr.Molle Apr 01 '14 at 22:32
  • Maybe it's useful for you: [What is the Proper Way to Destroy a Map Instance?](https://stackoverflow.com/questions/10485582/what-is-the-proper-way-to-destroy-a-map-instance) – Roman Oct 09 '17 at 08:51

0 Answers0