<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.23588"></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>have you registered your event?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>something like that, should do the job:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>xgis.map.prototype.initialize = function(name)
{<BR> ...<BR> ...</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial> this.events = new
OpenLayers.Events(this,<BR>
null,<BR>
['groupadded'],<BR>
false,<BR>
{includeXY: true});</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial> this.events.register("groupadded", this,
function (e) {<BR> alert("group layer
added");<BR> });<BR>
<BR>};</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>xgis.map.prototype.addGroup = function(name)
{<BR> /* CODE FOR ADDING A GROUP */<BR> /*
Trigger when group is added */<BR>
this.events.triggerEvent('groupadded', group);<BR>};<BR></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>Regards,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=656515611-22082014><FONT color=#0000ff
size=2 face=Arial>Arnd</DIV></FONT></SPAN><BR>
<DIV dir=ltr lang=de class=OutlookMessageHeader align=left>
<HR tabIndex=-1>
<FONT size=2 face=Tahoma><B>Von:</B> openlayers-users-bounces@lists.osgeo.org
[mailto:openlayers-users-bounces@lists.osgeo.org] <B>Im Auftrag von </B>Joćo
Rodrigues<BR><B>Gesendet:</B> Donnerstag, 21. August 2014 12:14<BR><B>An:</B>
openlayers-users@lists.osgeo.org<BR><B>Betreff:</B> [OpenLayers-Users] How to
add custom events to OpenLayers-based API?<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV dir=ltr>
<DIV>Hi</DIV>
<DIV><BR></DIV>
<DIV>I am woking on a GIS API built on top of OpenLayers. I have a class called
xgis.group, which represent a group of layers.</DIV>
<DIV>I want to add an event that can be triggered when a group is added.</DIV>
<DIV><BR></DIV>
<DIV>For example, in the map, I have tried this without success:</DIV>
<DIV><BR></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: rgb(204,204,204) 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex"
class=gmail_quote><FONT color=#0000ff>
xgis.map.prototype.addGroup = function(name) {</FONT><FONT
color=#0000ff><BR></FONT><FONT color=#0000ff> /*
CODE FOR ADDING A GROUP */</FONT><FONT color=#0000ff><BR></FONT><FONT
color=#0000ff> /* Trigger when group is added
*/<BR></FONT><FONT color=#0000ff>
this.events.triggerEvent('groupadded', group);<BR></FONT><FONT
color=#0000ff> };</FONT></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>I don't know how to deal with custom-made events.</DIV>
<DIV><BR></DIV>
<DIV>Could you lend me some help, please?</DIV>
<DIV><BR></DIV>
<DIV>Thanks</DIV></DIV>
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
<tr>
<td style='border:none;padding:0px 15px 0px 8px'>
<a href="http://www.avast.com/">
<img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" />
</a>
</td>
<td>
<p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
Diese E-Mail ist frei von Viren und Malware, denn der <a href="http://www.avast.com/">avast! Antivirus</a> Schutz ist aktiv.
</p>
</td>
</tr>
</table>
<br />
</BODY></HTML>