This project has moved and is read-only. For the latest updates, please go here.

How to do Drag and Drop on a single VectorLayer?

Topics: SharpMap Project
Aug 3, 2015 at 3:39 PM

Is it possible to do a drag and drop on a single VectorLayer with SharpMap?

My intention is to drag and drop a layer from one point on the map to another.

I have initially came up with some code but it seems that the behavior is similar to a Pan movement eventhough I specifically disabled the PAN Tool. Aside from that, all the other VectorLayers on the map move with the mouse as well.

Hoping for your help.

Thank you very much.

Best Regards,
Aug 7, 2015 at 8:58 AM
You want to translate (== move in x- and/or y-direction) the geometries of the layer?
That is not supported out of the box.

To get the translation you would have to set MapBox.ActiveTool to None and subscribe to the MapBox.MapMousedown and MapBox.MapMouseUp event.
If you store the location of the MapMouseDown event, you can calculate the translation vector in the MapMouseUp event.

If you have that, you have to somehow apply this information to the data represented in the layer. You could implement some affine transformation and apply that to the layers coordinatetransformation property.