<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000099">
    <font size="-1"><font face="Verdana">You are creating a new function
        each time you register a listener. Create the function
        beforehand and pass it everywhere. It could be that the
        unregistering requires to pass the active handler itself, not
        another function that just acts the same, but is not the same
        function instance.<br>
        <br>
        Janis<br>
        <br>
      </font></font><br>
    On 2011.10.04. 3:48, Puneet Kishor wrote:
    <blockquote
      cite="mid:DC24536E-00F4-40C8-ABC0-EB132D8211AB@gmail.com"
      type="cite">
      <pre wrap="">Seems like the problem I am encountering is that I am unable to "unregister" a "click" event from the map. Is there a way to ascertain if an event has been "unregister"ed successfully? (that is, besides, of course, discovering that it is still firing).


On Oct 3, 2011, at 6:44 PM, Puneet Kishor wrote:

</pre>
      <blockquote type="cite">
        <pre wrap="">I would welcome suggestions to solve the following. I want to "enable" the "activation" of a functionality at a certain zoom level, and after the functionality is completed, I want the "deactivate" the functionality, but still keep it enable-able (huh!). See below for a better description of the problem --


   // add a "zoomend" event so…
   map.events.register("zoomend", map, function() {

       // when the map is zoomed in at the correct level,
       if (map.getZoom() &gt; 3) {

           // a button is activated so that when the button is clicked…
           $("#button").bind("click", function() {

               // the button is turned "on"
               ..

               // the map begins listening for clicks to do 
               // cool functionality
               map.events.register("click", map, function(e) {
                   coolFunctionality(e);
               })
           });

       }

       // but when the map zoom is not at the correct level,
       else {

           // map is no longer listening to clicks
           map.events.unregister("click", map, function(e) {
               coolFunctionality(e);
           })

           // and the button is turned "off" and deactivated
           $("#button").unbind("click", function() {});   

       }
   });

In another part of the script

   "coolFunctionality": function (e) {

       // do cool functionality, 
       ..

       // turn the button "off" (but it can still be clicked)
       ..

       // and turn off the map listener so it may not be fired accidentally
       map.events.unregister("click", map, function(e) {
           coolFunctionality(e);
       })
   }

So, the problem is, when I am in `coolFunctionality()` and `unregister` the event, I am still in the zoom level range where the event is `register`ed. Hmmmm... what to do?

--
Puneet Kishor
</pre>
      </blockquote>
      <pre wrap="">
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/openlayers-users">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a>


</pre>
    </blockquote>
  </body>
</html>