current marker position

Topics: Windows Forms
Apr 5, 2011 at 12:29 PM
Edited Apr 5, 2011 at 12:41 PM

Hi! I have an Question:

how can I determine the current position:

when I click on the marker ->

Private Sub GMapControl1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.MouseDown
      
            If GMapControl1.IsMouseOverMarker Then
                labelLat.text =  ??????????

                labelLng.text= ??????????
end if

    End Sub

i take VB 2010

thanx

Apr 5, 2011 at 12:41 PM
Edited Apr 5, 2011 at 12:41 PM

just use MainMap.OnMarkerClick += new MarkerClick(MainMap_OnMarkerClick);

void MainMap_OnMarkerClick(GMapMarker item, MouseEventArgs e)
{
   item.Position

...

.. if you just wanna know local position without any markers, use:

void MainMap_MouseDown(object sender, MouseEventArgs e)
{
    if(e.Button == MouseButtons.Left)
    {
      currentMarker.Position = MainMap.FromLocalToLatLng(e.X, e.Y);

Apr 5, 2011 at 12:59 PM
Edited Apr 5, 2011 at 1:01 PM

Thanks for your fast answer!

 

The Code dose not work!

can you tell me the code in VB.net?

Not working:

Private Sub GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
        MsgBox(item.Position)

    End Sub

Thank you

Apr 5, 2011 at 1:01 PM

i don't know vb ;/ but the functions are the same ;}

Apr 5, 2011 at 3:50 PM

Hi! follow code:

Private Sub GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
        txtstrasse.Text = (item.Position.Lat)
    End Sub

when i click on the Marker (real lat position is "48,0112860988103")

but the right position is "48,0112502116883"

do you now what's the problem?

Apr 6, 2011 at 7:14 AM

One Problem!
something is the Position ident but somthing not (I think that's a zoom Problem)

Can i assign an ID to the Marker?

Apr 6, 2011 at 7:35 AM

you can use Tag field, or make your own