[OpenLayers-Dev] Destroying popups with abandon

Erik Uzureau euzuro at gmail.com
Wed Feb 4 19:02:11 EST 2009


This looks great, Paul. Can you make a ticket and patch for this? :-)
Erik

On Wed, Feb 4, 2009 at 15:41, Paul Dziemiela <paul at dziemiela.com> wrote:

> Hello,
>
> In some cases I need to "clear the decks" of popups and would like to
> simply
> blast away with the destroy() function anywhere that feature.popup is not
> null.  However, when I try this against features that haven't actually
> created a popup I get several errors.  Is it reasonable to expect destroy()
> to execute in any case without errors?
>
> The following changes would be needed to destroy() in Framed.js
>
>    destroy: function() {
>       this.imageSrc = null;
>       this.imageSize = null;
>       this.isAlphaImage = null;
>
>       this.fixedRelativePosition = false;
>       this.positionBlocks = null;
>
>       //remove our blocks
>       // Added this test
>       if (this.blocks != null) {
>          for(var i = 0; i < this.blocks.length; i++) {
>             var block = this.blocks[i];
>
>             if (block.image) {
>                block.div.removeChild(block.image);
>             }
>             block.image = null;
>
>             if (block.div) {
>                this.groupDiv.removeChild(block.div);
>             }
>             block.div = null;
>          }
>       }
>       this.blocks = null;
>
>       OpenLayers.Popup.Anchored.prototype.destroy.apply(this, arguments);
>    },
>
> And the following changes to destroy() in Popup.js
>
>    destroy: function() {
>
>       this.id = null;
>       this.lonlat = null;
>       this.size = null;
>       this.contentHTML = null;
>
>       this.backgroundColor = null;
>       this.opacity = null;
>       this.border = null;
>
>       if (this.events != null) {
>          this.events.destroy();
>       }
>       this.events = null;
>
>       if (this.closeDiv != null) {
>          OpenLayers.Event.stopObservingElement(this.closeDiv);
>          this.groupDiv.removeChild(this.closeDiv);
>       }
>       this.closeDiv = null;
>
>       if (this.div != null) {
>          this.div.removeChild(this.groupDiv);
>       }
>       this.groupDiv = null;
>
>       if (this.map != null) {
>          this.map.removePopup(this);
>       }
>       this.map = null;
>       this.div = null;
>
>       this.autoSize = null;
>       this.minSize = null;
>       this.maxSize = null;
>       this.padding = null;
>       this.panMapIfOutOfView = null;
>    },
>
> Thanks!
>
> Paul
>
>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20090204/3766b2a7/attachment.html


More information about the Dev mailing list