How can i drag a marker?

Topics: Windows Forms
Nov 24, 2011 at 5:02 PM

Hello i got a question, i looking on the code of the example of the windows form and i don't find information or code about the possibility of drag markers, in the example this can possible but i don't find how can i do it? thats my code for put a marker on the map:

private void button1_Click(object sender, EventArgs e)
        {
            //top = new GMapOverlay(GMap, "SSC - GMaps");
            GMap.Overlays.Add(Capa);
            
            Marcador.ToolTipMode = MarkerTooltipMode.OnMouseOver;
            
            Placemark localizarLugar = null;
            GeoCoderStatusCode status;
            var ret = GMapProviders.GoogleMap.GetPlacemark(Marcador.Position, out status);
            if (status == GeoCoderStatusCode.G_GEO_SUCCESS && ret != null)
            {
                localizarLugar = ret;
            }
            if (localizarLugar != null)
            {
                Marcador.ToolTipText = localizarLugar.Address;
            }
            else
            {
                Marcador.ToolTipText = Marcador.Position.ToString();
            }
            Marcador.Tag = "2011000086";
            Marcador.ToolTipText = Marcador.ToolTipText + "Fecha y Hora: " + DateTime.Now.ToString() + "\n No. de Solicitud: " +Marcador.Tag+  "\n Estatus: En Atencion.";
                        
            Capa.Markers.Add(Marcador);            
        }

In that code how i can able the option for the marker can be draggable, thanks in advance.

Coordinator
Nov 24, 2011 at 5:28 PM

start exploring demo source ;} there is no better way to learn something

Nov 24, 2011 at 10:03 PM

I'm do it man but i can't find exactly that thing, i look something with the rectangle over the marker but i want to do it witout that rectangle only the marker.

Coordinator
Nov 25, 2011 at 6:31 AM

MainMap.MouseMove += new MouseEventHandler(MainMap_MouseMove);

void MainMap_MouseMove(object sender, MouseEventArgs e)
{
   Marker.Position = MainMap.FromLocalToLatLng(e.X, e.Y);
}

Nov 29, 2011 at 4:32 PM

Thanks for the answer i really appreciate the attention, but that's not exactly the thing i want to do, that code works for the markers follow the mouse movement but i want to drag a marker with this form:

I want to put a marker on the map, and drag that only when i put the mouse over the marker press clic on it hold it and when i move the mouse the marker follows the position of the mouse, and only when i release the clic of the mouse, the marker will be placed on the site of the mouse position, but only when i press a clic on it, sorry for the discomfort but i continue looking on the code and i don't find exactly that part and i prove it on the example and that is possible thanks in advance.