title: can't unregister click event in openlayers
body: <p>I am having issues with OpenLayers and unregistering the click events that are added to a layer. Basically, what I need to do is this:</p>
  
  <p>When a user clicks on a marker, they get a bubble that has an "edit" link in it. The user clicks that and it creates a new layer on the map and then registers a click event to the map waiting for the user to click on the map. When they click somewhere on the map, it then moves the marker to where they clicked. This all works perfectly.</p>
  
  <p>However, the issue is when the user clicks to edit the marker and then clicks on a button OUTSIDE OF THE MAP to cancel the action and NOT move the marker, the unregister of the click event doesn't work. They can still click on the map and it moves the marker.</p>
  
  <p>Here is a sample of the code:</p>
  
  <pre><code>function move_marker(marker) {
      lmLayer = new OpenLayers.Layer.Markers("Landmark Creation",{displayInLayerSwitcher: false});
      map.addLayer(lmLayer);
      map.events.register("click", lmLayer, function(evt){
          var pixel = new OpenLayers.Pixel(evt.clientX,evt.clientY);
          position = map.getLonLatFromPixel(pixel);
          marker.lonlat = pixel;
          marker.moveTo(pixel);
          marker.draw();
          lmLayer.redraw();
          OpenLayers.Event.stop(evt);
      });
  }
  function cancel_move() {  // this function is triggered by a button outside of the map element
      lmLayer = map.getLayersByName('Landmark Creation');
      lmLayer[0].events.unregister("click");
      map.events.unregister("click");
      map.removeLayer(lmLayer[0]);
  }
  </code></pre>
  
  <p>As you can see in the cancel function, I am getting the layer by the layer name, which according to the console.log it is finding at index 0. I added the unregister to the lmLayer in hopes that would help, but so far, no luck. Then on the map element I add the unregister call and then finally I remove that new layer because we don't want it interfering.</p>
  
  <p>I'd appreciate some feedback on this. I'm losing my mind.</p>
  
  <p>Thanks!</p>