Hi Eric,

Maybe I am misunderstanding the use of the control entirely.. I got this code 
from a previous example and the way I am using the control is -

Declare it like so

//Define Hotspot Control
  var info_hotspots = new OpenLayers.Control.WMSGetFeatureInfo({
  url: 'http://localhost/WebServices/Request.aspx',
  title: 'hotspots',
  queryVisible: false,
  infoFormat: 'text/xml',
  layers: [layer_Parcels_Hotspot],
  maxFeatures: 1,
  hover:false
  });
  info_hotspots.handler.delay = 1;


And then I have a giant function to actually process the request and do stuff 
that begins like- 

 info_hotspots.events.on({
             getfeatureinfo: function(e) { 
                //do stuff here
                };

Well I have many different themes that the user switches maps to and so I need 
the control to use different layers and output different things so I was 
modifying the info_hotspots.events.on by basically redeclaring it.. However 
this was not working I don't think. So do I just unregister the event first and 
then make a new one again so the new one will only fire? 




-----Original Message-----
From: Eric Lemoine [mailto:[email protected]] 
Sent: January 23, 2011 6:35 AM
To: Andrew Stewart
Cc: [email protected]
Subject: Re: [OpenLayers-Users] Unregistering an event for wmsgetfeatureinfo?

On Sat, Jan 22, 2011 at 4:36 AM, Planet)x <[email protected]> wrote:
>
> I have a GetFeatureInfo control which I declare then in myfeature.events.on I
> code the event. My question is I am trying to use this same control again
> but with a different layer this time so I modify the events.on by redefining
> it.. however it is still firing the first events.on. So do I have to
> unregister the first event.. and if so how to do that.. is it simply
> following the events object listed here -
> http://dev.openlayers.org/docs/files/OpenLayers/Events-js.html
> and using myfeature.unregister(myfeature.events.on) .. or how ? Appreciate
> any assistance.

I'm not sure I understand your issue, if you can unregister listeners using

control.events.un({"eventname": callback_reference});

For example:

function cb() {};
control.events.on({"eventname": cb});
control.events.un({"eventname": cb});

You need to keep references on callbacks you want to eventually unregister.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com


[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the 
environment before printing this e-mail.]




_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to