[OpenLayers-Users] Destroy not being called for popups?

Christopher Schmidt crschmidt at metacarta.com
Mon Sep 3 10:19:15 EDT 2007


On Mon, Sep 03, 2007 at 11:20:14AM +1000, Glen Stampoultzis wrote:
> On 31/08/07, Christopher Schmidt <crschmidt at metacarta.com> wrote:
> >
> > On Fri, Aug 31, 2007 at 04:12:54PM +1000, Glen Stampoultzis wrote:
> > > Hi...
> > >
> > > just been mucking around with popups and I noticed that the destroy
> > method
> > > does seem to get called.  The close poup button just hides the div from
> > what
> > > I can tell and the map.removePopup() call seems to remove the div from
> > the
> > > DOM without calling destroy and cleaning up the event handlers.
> > >
> > > Bug or feature?
> >
> > When would you call destroy? Certainly, a popup can be removed from the
> > map without it being destroyed: it can be re-added at a later time, and
> > we use that behavior in some applications here at MetaCarta.
> >
> > In general, removing things is not the same as destroying them, and
> > depending on when they are created, you may have to clean up after
> > yourself rather than depending on OpenLayers to do it for you.
> >
> > If you use a feature to create the popup, it destroys the popup for
> > you. If you create your own, you're on your own.
> >
> >
> It's just that popup doesn't provide any way for you to attach an event
> indicating the user has closed the popup using the close button so how do
> you know when to destroy?

You probably don't want to destroy when the user closed the popup
anyway: It's still attached to the map at that point, no? 

One possibility is just to destroy it when the window is closed -- but
really, if there's still any popups on the map when the page is
unloaded, we should be destroying them. I've opened ticket #955 for
that. Would that be enough to solve the problem? Is destroying the
popups during your application's running important?  

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list