<p>Hi Everyone,</p>

<p>Hi have what I though would be a simple task but its proving to be a little more frustrating than I anticipated.

<p>What I need to do is get the coordinates for pan events so that I know the coordinates of when the drag started and when it ended. The logical way to do this as far as I thought was to listen for the mousedown (or movestart) and mouseup (or moveend) events and get the coordinates from there. Its not behaving the way I anticipated though. I've tried a whole bunch of different ideas - four of which I'll list here. Surely one of these is close.  I think the first two are the closest.

<p>I'd very much appreciate any input that may help.

<p>Many Thanks<br>
Dave

<br><br>
<p><b>Method 1.</b> <i>Not all Events are recevied and of the ones that are I can't get the coordinates from all of them.</i>

<li>click: yes
<li>mousemove: yes
<li>mouseup: yes
<li>mousedown: no
<li>movestart: yes - but coordinates recevied are NAN
<li>moveend: yes - but coordinates received are NAN

<pre>
   var options =
   {   
       ... other settings....

      eventListeners: {
         "movestart": doEvent
      }
   };

   function doEvent(event) {
      var obj = this.events.getMousePosition(event);
      alert(obj);
    }
</pre>

<p><b>Method 2.</b> <i>Same results as Method 1</i>

<pre>
   map.events.register("mousemove", map, function(e) {
      var position = this.events.getMousePosition(e);
      alert(position);
   });

</pre>


<p><b>Method 3.</b> <i>Clicks are called but not mousedowns.</i>

<pre>
   OpenLayers.Control.Click = OpenLayers.Class(OpenLayers.Control, {
      defaultHandlerOptions: {
         'single': true,
         'double': false,
         'pixelTolerance': 0,
         'stopSingle': false,
         'stopDouble': false
      },

      initialize: function(options) {
         this.handlerOptions = OpenLayers.Util.extend(
         {}, this.defaultHandlerOptions
            );
         OpenLayers.Control.prototype.initialize.apply(
            this, arguments
            );
         this.handler = new OpenLayers.Handler.Click(
            this, {
            'click': this.doClick,
            'down': this.doDown,
            'mousedown': this.doMouseDown
         }, this.handlerOptions
            );
      },

      doClick: function(e) {
         alert('click');
      },
      doDown: function(e) {
         alert('down');
      },
      doMouseDown: function(e) {
         alert('mouseDown');
      }
   });
</pre>

<b>Method 4.</b>  <i>Callbacks are only received if Navigation is deactivated.</i>

<pre>
   OpenLayers.Control.Drag = OpenLayers.Class(OpenLayers.Control, {
       defaultHandlerOptions: {
           stopDown: false
       },

       initialize: function(options) {
           this.handlerOptions = OpenLayers.Util.extend(
               {}, this.defaultHandlerOptions
           );
           OpenLayers.Control.prototype.initialize.apply(
               this, arguments
           );
           this.handler = new OpenLayers.Handler.Drag(
               this, {
                   'down': this.doDown,
                   'up': this.doUp,
                   'move': this.doMove,
                   'done': this.doDone
               }, this.handlerOptions
           );
       },

       doDown: function(e) {
           alert('down');
       },
      doUp: function(e) {
           alert('up')
      },
      doMove: function(e) {
           alert('move');
       },
      doDone: function(e) {
           alert('done');
       }
   });

</pre>
<br><hr align="left" width="300">
View this message in context: <a href="http://n2.nabble.com/Mouse-Drag-Coordinates-tp3916580p3916580.html">Mouse Drag Coordinates</a><br>
Sent from the <a href="http://n2.nabble.com/OpenLayers-Users-f1822463.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br>