[OpenLayers-Users] Unable to understand the Initialize code?

Phil Scadden p.scadden at gns.cri.nz
Sun Aug 5 15:12:14 PDT 2012


> i am trying to understand the initialize code in the link 
> <http://dpaste.de/t214A/>.
>
> It is encapsulated in the OpenLayers.Click command,
>
> OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, { link 
> <http://dpaste.de/t214A/> });
>
> I am not able to understand what exactly the initialization code is 
> doing and what 'this' implies?

First, you dont need to understand this to use it. You would work with 
this in openlayers by manipulating openlayer.control properties. This is 
code for creating a new descendent of an openlayers control. The kind 
that live in openlayers/lib/control.

If you havent worked with OO languages, this probably isnt the best 
place to start.

Anyway, the basics of it are to create a new descend of the 
openlayer.control class. when your code does a myvar = new 
Openlayers.control.click, then the initialise code is called. "this" is 
the way you refer to owner of the function - the specific instance of 
the class. What the code does is:
  - combines the various options into the handleroptions property.
  - call the prototype (Openlayers.control) initialize method
  - set the handler property of the handler to be a new instance of the 
openlayers click handler control, using the handleroption property.

A javascript language reference text would be a good place to go. The 
openlayers list isnt really a place to learn javascript.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120806/12171e7d/attachment.html>


More information about the Users mailing list