Yes, the destructor needs to be called manually, but calling it
eliminates possible memory leaks.
See below a destructor for the marker (pin) object that you see on a
map. This destructor also destroys the events object, which is a
property of marker.
/**
* APIMethod: destroy
* Destroy the marker. You must first remove the marker from any
* layer which it has been added to, or you will get buggy behavior.
* (This can not be done within the marker since the marker does not
* know which layer it is attached to.)
*/
destroy: function() {
this.map = null;
this.events.destroy();
this.events = null;
if (this.icon != null) {
this.icon.destroy();
this.icon = null;
}
},
On 9/24/07, Jeff Watkins <[EMAIL PROTECTED]> wrote:
>
> How would you implement a destroy or destructor function since
> JavaScript doesn't support it? Do you manually call the method?
>
> On Sep 24, 2007, at 11:24 AM, Les wrote:
>
> >
> > Ryan,
> >
> > Did you notice that each OpenLayers class has a destructor (destroy)
> > and a property denoting the class name?
> >
> > I don't see such a destructor in Prototype or Dojo, see below:
> >
> > OpenLayers.Map = OpenLayers.Class({
> > ....
> > initialize: function (div, options) {
> > },
> > ....
> > destroy:function() {
> > },
> > CLASS_NAME: "OpenLayers.Map"
> > });
> >
> >
> > >
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---