什么是销毁地图实例的正确方法? [英] What is the Proper Way to Destroy a Map Instance?

查看:898
本文介绍了什么是销毁地图实例的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开发了一个html5移动应用程序。该应用程序是导航哈希更改事件替换整个DOM的单个页面。应用程序的一部分是使用API​​ v3的Google Map。在将DOM从DOM中删除之前,我想删除任何事件处理程序/侦听器,并释放尽可能多的内存,因为用户可能不会再返回到该部分。



破坏地图实例的最好方法是什么?

正式答案是不是。



对于某些单页面应用程序,这可能意味着需要重新设计解决方案,以便一旦映射完成被创建它可能隐藏或断开与DOM,但它永远不会被销毁/重新创建。


I recently developed an html5 mobile application. The application was a single page where navigation hash change events replaced the entire DOM. One section of the application was a Google Map using API v3. Before the map div is removed from the DOM, I want to remove any event handlers/listeners and free up as much memory as possible as the user may not return to that section again.

What is the best way to destroy a map instance?

解决方案

The official answer is you don't. Map instances in a single page application should be reused and not destroyed then recreated.

For some single page applications, this may mean re-architecting the solution such that once a map is created it may be hidden or disconnected from the DOM, but it is never destroyed/recreated.

这篇关于什么是销毁地图实例的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆