[OpenLayers-Users] Custom Controls
André Matos
andre.matos at co.sapo.pt
Thu Dec 18 12:44:23 EST 2008
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:
MyControl = OpenLayers.Class(OpenLayers.Control, {
//Constructor
initialize: function(){
alert("ctr");
},
//called when the user adds the control to the map. if the control
wants to display information
draw: function(){
OpenLayers.Control.prototype.draw.apply(this);
var div = document.createElement("div");
div.style.width = "100px";
div.style.height = "100px";
div.style.background = "black";
this.div.appendChild(div);
return this.div;
},
//called when the user removes the control from the map
destroy: function(){
OpenLayers.Control.prototype.destroy.apply(this);
alert("destroy");
},
CLASS_NAME: "MYCONTROL"
});
Is this the best way to implement custom controls? Will OpenLayers
developers change the not API methods, initialize, draw, destroy or the div
property defined at Control Class?
I need to know because I want to integrate future releases.
The second question is: Why does Control.destroy method exist? This is the
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
Thanks.
André Matos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081218/ed89a383/attachment.html
More information about the Users
mailing list