[OpenLayers-Users] How to add custom events to OpenLayers-based API?

João Rodrigues joaorodr84 at gmail.com
Mon Sep 15 05:43:41 PDT 2014


Hi Arnd.

Sorry for the late response.

It worked. :)

Thank you very much.

João


2014-08-22 12:59 GMT+01:00 Arnd Wippermann <arnd.wippermann at web.de>:

>  have you registered your event?
>
> something like that, should do the job:
>
> xgis.map.prototype.initialize = function(name) {
>     ...
>     ...
>
>     this.events = new OpenLayers.Events(this,
>                                         null,
>                                         ['groupadded'],
>                                         false,
>                                         {includeXY: true});
>
>     this.events.register("groupadded", this, function (e) {
>         alert("group layer added");
>     });
>
> };
>
> xgis.map.prototype.addGroup = function(name) {
>     /* CODE FOR ADDING A GROUP */
>     /* Trigger when group is added */
>     this.events.triggerEvent('groupadded', group);
> };
> Regards,
> Arnd
>
>  ------------------------------
> *Von:* openlayers-users-bounces at lists.osgeo.org [mailto:
> openlayers-users-bounces at lists.osgeo.org] *Im Auftrag von *João Rodrigues
> *Gesendet:* Donnerstag, 21. August 2014 12:14
> *An:* openlayers-users at lists.osgeo.org
> *Betreff:* [OpenLayers-Users] How to add custom events to
> OpenLayers-based API?
>
>  Hi
>
> 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.
> I want to add an event that can be triggered when a group is added.
>
> For example, in the map, I have tried this without success:
>
>     xgis.map.prototype.addGroup = function(name) {
>>         /* CODE FOR ADDING A GROUP */
>>         /* Trigger when group is added */
>>         this.events.triggerEvent('groupadded', group);
>>     };
>
>
> I don't know how to deal with custom-made events.
>
> Could you lend me some help, please?
>
> Thanks
>
>
> ------------------------------
>    <http://www.avast.com/>
>
> Diese E-Mail ist frei von Viren und Malware, denn der avast! Antivirus
> <http://www.avast.com/> Schutz ist aktiv.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140915/7a626f99/attachment.html>


More information about the Users mailing list