[OpenLayers-Users] How to implement draggable Markers?

Alan Boudreault aboudreault at mapgears.com
Fri Jan 9 10:33:21 EST 2009


I think that's why the "mouseup" event was register with Priority......
it's this event that stop the mousemove one.  Just add a boolean member
"DragEnabled" and the mousemove event will do it's work only if the this
variable is set.

Alan

KartoPete wrote:
> good idea, 
> I tried first version and can't stop the mousemove event. Any ideas? If it
> would be my own code I would do it different, but I#m stuck in many code
> from another author, who worked on the project before. My actuell
> DraggableMarkerClass looks like this:
> OpenLayers.Marker.DraggableMarker = OpenLayers.Class(OpenLayers.Marker, {
> 	
> 	layer: null,
> 	currentEvent: null,
> 	
> 	registerEvents: function(){
> 		this.events.registerPriority('mousedown', this, this.onMarkerDown);
> 		this.map.events.register('mouseup', this, this.onMarkerUp);
> 	},
> 	
> 	onMarkerDown: function(){
> 		this.map.events.register('mousemove', this, this.onMove);
> 	},
> 	onMarkerUp: function(){
> 		
> 		Event.stop(this.currentEvent);
> 		
> 	},
> 	onMove: function(e){
> 		 	var lonlat = this.map.getLonLatFromViewPortPx(e.xy);
> 		 	var marker = new OpenLayers.Marker.DraggableMarker(new
> OpenLayers.LonLat(lonlat.lon,lonlat.lat), markerIcon2.clone());
> 		 	this.layer.clearMarkers();
> 		 	this.layer.addMarker(marker);
> 		 	this.currentEvent = e;
> 	},
> 	
> 	
>     CLASS_NAME: "OpenLayers.Marker.DraggableMarker"
> });
>
> As I already said, I can't stop the mousemove-Event!
> Any ideas?
> thx,
> Pete
>   


-- 
Alan Boudreault
Mapgears
http://www.mapgears.com




More information about the Users mailing list