ThinkGeo.com    |     Blog    |     Wiki    |     Support

Draggable marker position

Hi,

I use a draggable marker and I want to know its position when I move the marker. I used the marker.MarkerMouseUp event but I get the previous position of the marker. How can I get the current position of the marker?

Hi Marios,

If you move a draggable marker, the MarkerMouseUp event should be performed before you move the marker, so the position is where it from.

Why not use the event MarkerMouseDown?

If I misunderstand your question please let me know.

Regards,

Ethan

I will change my question to be more specific. I have a draggable marker and two textboxes, one for lantitude and one for lonftitude of the marker. I want during the movement of the marker the text of the texboxes to change and have the current values of the marker latlon. Haw can Ido this?

Hi Marios,

Here is a sample, wish that’s helpful.

9649.zip (101.9 KB)

You can update coordinates in MarkerMouseMove event of marker.

For make sure whether a marker is dragged, you can choose two solution:

Event MarkerDragging & MarkerDragged
or
Event MarkerMouseDown & MarkerMouseUp

You can find them in the sample code.

Wish that’s helpful.

Regards,

Ethan

Hi Ethan,

The code you uploaded was very helpful.
Thank you!

Hi Marios,

I am glad to hear that’s helpful.

Regards,

Ethan

Hi Ethan,
In the example you sent me I noticed that when the mouse is on the marker you cannot zoom in-out.
How you can overcome this?

Hi Mario,

You can add event to handle it:

marker.MouseWheel += Marker_MouseWheel;

    private void Marker_MouseWheel(object sender, System.Windows.Input.MouseWheelEventArgs e)
    {
        Debug.WriteLine(e.Delta);

        if (e.Delta > 0)
        {
            map.ZoomIn();
        }
        else if (e.Delta < 0)
        {
            map.ZoomOut();
        }
    }

Wish that’s helpful.

Regards,

Ethan