[OpenLayers-Users] Draggable Markers on Openlayers.

BenJamin2007 ukliming at hotmail.com
Fri Oct 12 21:26:31 EDT 2007


Hi guys,

I downloaded the draggable Marker feature from 

http://trac.openlayers.org/browser/sandbox/tschaub/feature/lib/OpenLayers/Control/DragMarker.js?rev=3459

and I make it work.

This feature will be released on version 2.6 I guess. But I would like to
put it forward because I have to use it for my current work.

Basically, there are 2 fundamental 'classes':

OpenLayers.Control.DragMarker
OpenLayers.Handler.Marker

This is how we add drag control to the markers.::::


map = new OpenLayers.Map('map');
markermanager = new OpenLayers.Layer.Markers(" marker layer ");
var DragControl=new OpenLayers.Control.DragMarker(markermanager);
map.addControl(DragControl);
DragControl.activate();


Easy, Simple, Good!

I also had this code in my javascript:

a_marker=new OpenLayers.Marker(new OpenLayers.LonLat(-72,42));
a_marker.events.register("mouseup", null, function(evt){
     // Do something.
    333                           // option 2: intend to creat an error
here.
}

But here is my Problem: If I add the customer event handler....         When
I drag the a_marker, I can drag it.. but after I release my left button, the
a_marker won't go release.. The marker keep sticking to the mouse.  Seems
that the 'mouseup' event has not been passed to the DragHandler.....

The ONLY way I can solve this problem is to create an error at the end of
the event function, like this:

a_marker.events.register("mouseup", null, function(evt){
     // Do something.
    333     // intend to creat an error here.
}




Here are the ways I tried, but failed!!!!

a_marker.events.register("mouseup", a_marker, function(evt){
       // Do something.
      map.Event.Stop(evt);                      
 }

a_marker.events.register("mouseup", map, function(evt){
       // Do something.
      map.Event.Stop(evt); 
}

a_marker.events.register("mouseup", null, function(evt){
       // Do something.
      map.Event.Stop(evt);                       
}



SO, Some body Help me. 

Thank a lot!!!

-- 
View this message in context: http://www.nabble.com/Draggable-Markers-on-Openlayers.-tf4616114.html#a13183278
Sent from the OpenLayers Users mailing list archive at Nabble.com.




More information about the Users mailing list