[OpenLayers-Users] Custom Controls
André Matos
andre.matos at co.sapo.pt
Fri Dec 19 05:38:43 EST 2008
I think it is a bug caused for it, because the destroy method or another
method is not called to unregister events of behavior controls.
For example, if you add a Navigation Control to your map, and then remove
it, the functionality is not removed (as expected).
Thanks,
André Matos
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of André Matos
Sent: sexta-feira, 19 de Dezembro de 2008 10:32
To: 'Christopher Schmidt'
Cc: Users at openlayers.org
Subject: Re: [OpenLayers-Users] Custom Controls
Are there any method at Control class that is called when the users remove
their controls from the map? That were nice, because when the controls are
added to map, the draw method are called (there you register in events,
handlers etc...), and when the control is removed was nice to unregister
that events to stop the functionality.
The description of destroy method says that:
Method: destroy
The destroy method is used to perform any clean up before
the control
is dereferenced. Typically this is where event listeners
are removed
to prevent memory leaks.
Typically the control is dereferenced when the programmer removes it from
the map (map.removeControl), and it was helpful to unregister events if the
control affect the map's behavior.
Thanks
André Matos
-----Original Message-----
From: Christopher Schmidt [mailto:crschmidt at metacarta.com]
Sent: quinta-feira, 18 de Dezembro de 2008 18:17
To: André Matos
Cc: Users at openlayers.org
Subject: Re: [OpenLayers-Users] Custom Controls
On Thu, Dec 18, 2008 at 05:44:23PM -0000, André Matos wrote:
> Hi Guys!
>
>
>
> I am starting on OpenLayers API and I have two questions
>
>
>
> I am studing the controls and I have notice that, theres no API methods
or
> API properties in Control type. That means the open layers developers can
> change it, without any advise.
>
> The way I am doing my controls is this:
>
> Is this the best way to implement custom controls?
I think so.
> Will OpenLayers
> developers change the not API methods, initialize, draw, destroy or the
div
> property defined at Control Class?
I think it's fair to say we won't change any of those. I'll wait for
dissenting opinions before changing the docs.
> description in the Control Class destroy method:
>
>
>
> Method: destroy
>
> * The destroy method is used to perform any clean up before the
control
>
> * is dereferenced. Typically this is where event listeners are
removed
>
> * to prevent memory leaks.
>
>
>
> But it Is never called. The control is dereferenced at Map.removeControl
> method, and this method does not call control.destroy method
Generally speaking, we try not to .destroy() anything we don't create --
meaning it would be up to application designers to destroy things.
When the map itself is destroyed, we do destroy any control associated
with it -- but removing a control is not equivilant to wanting it
destroyed. Instead, it's a sign that the control should no longer be
visible on the map. The user might then take that same control and addi
t back to the map later.
So, this is just representative of our conservative destruction
philosophy.
Regards,
--
Christopher Schmidt
MetaCarta
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list