Index of selected Marker (Map_OnMarkerEnter)

Topics: Windows Forms
Mar 31, 2011 at 9:41 AM

Hello,

I programming under vb.net (visual basic) by using the GmapControl.

How i can get the index of the a marker by using "Map_OnMarkerEnter".

I hope anyone can help me. I search for a solution several times, but i cannot
find a solution to solve the problem (e.g. marker.SelectedIndex ).

excuse for my english...

jsk001

Mar 31, 2011 at 10:27 AM

void MainMap_OnMarkerEnter(GMapMarker item) { item.Tag ...

or some another custom field...

Mar 31, 2011 at 10:45 AM

Hi @Radioman

I programming under MS Visual Basic 2008.

I need the index of the actual marker ( if the mouse is over them) but i cannot find

information about that.

e.g.

Private Sub Map_OnMarkerEnter(ByVal item As GMap.NET.WindowsForms.GMapMarker) Handles Map.OnMarkerEnter
        Label2.Text = item.Tag
        pos = item.Position
       CurrentMarker= ?????????????? <-----------------------
 End Sub

to remove an marker i like to use the following

    Private Sub Map_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Map.OnMarkerClick
        If e.Button = Windows.Forms.MouseButtons.Right Then
            If CurrentMarker > 0 Then
                Map.Overlays.RemoveAt(CurrentMarker)
                Map.Invalidate()
                Map.Refresh()
            End If
        End If
    End Sub

 

best regards

jsk001

Mar 31, 2011 at 11:35 AM

Map.Overlays.RemoveAt(CurrentMarker) // thats nonsence

all you need to do is markers.Remove(item);

Mar 31, 2011 at 2:11 PM
Edited Mar 31, 2011 at 2:13 PM

Hello @radioman,

 

thanks for your fast answer but it doesn't working by using GmapControl under Visual BAsic 2008.

Error-msg.:

Error:    "Remove" ist kein Member von "GMap.NET.WindowsForms.GMapMarker".   

Source code:

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

I hope I make you too not much trouble.

friendly regards

jsk001

Mar 31, 2011 at 2:20 PM
Edited Mar 31, 2011 at 2:23 PM

List<int> l = new List<int>();
l.Add(1);
l.Remove(1);
Debug.WriteLine("count: " + l.Count);

it prints:

count: 0

so i guess, it works ;}

p.s. use yourOverlay.Markers.Remove(... 

Mar 31, 2011 at 2:31 PM
Edited Mar 31, 2011 at 2:34 PM

hello,

thanky for your reply.

yes, that's right, but I need the index of each marker, above over them is just the mouse pointer.

sample ( but in uncorrect syntax of vb2008):

Private Sub GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
        Map.Overlays.RemoveAt(selectedindex.item) <---------????????????
End Sub

Map.Overlays.RemoveAt(0)...Map.Overlays.RemoveAt(1)...etc is working

...i search for the correct syntax...

friendly regards.

jsk001

Mar 31, 2011 at 3:06 PM

not exactly, you remove whole overlay for one marker, each overlay contains N marker, N routes and N polygons, so you need only remove marker from overlay object, not the overlay itself

Mar 31, 2011 at 3:24 PM

Hello @radioman,

i know what do you mean. My problem is, i cannot find the correct syntax to realize it in vb2008 by using

the GMapControl.

 

the following:

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

does't work.

the errormessage is:

Error 1    "Remove" is not a Member of "Markers". 

...I'll go crazy ;-)

best regards jsk001

 

 

Mar 31, 2011 at 3:30 PM

try Markers.Markers.Remove ;}

Mar 31, 2011 at 3:41 PM

hello @radioman,

Thank you for your endurance with me.

the following is working, but only for the last of the added markers.

if i click to the other markers it doesn't work.

Private Sub GMapControl1_MouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.MouseDoubleClick
        GMapControl1.Position = New PointLatLng(lat, lon)
        NewMarker = New GMapMarkerGoogleRed(GMapControl1.Position)
        NewMarker.TooltipMode = MarkerTooltipMode.OnMouseOver
        NewMarker.ToolTipText = "Lat: " & lat & vbCrLf & "Lng: " & lon
        Layer_Markers = New GMapOverlay(GMapControl1, "Layer_One")
        Layer_Markers.Markers.Add(NewMarker)
        GMapControl1.Overlays.Add(Layer_Markers)
        GMapControl1.Refresh()
    End Sub

Private Sub GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
   Layer_Markers.Markers.Remove(item)
End Sub


Mar 31, 2011 at 3:47 PM

because you create new layer for each new marker, makes no sense

Mar 31, 2011 at 3:57 PM

hello @radioman,

...wow, i'm so stupid...

i've move the following to the Form_Load routine and it work's great.

Layer_Markers = New GMapOverlay(GMapControl1, "Layer_One")
GMapControl1.Overlays.Add(Layer_Markers)

.....

Private Sub GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
        Layer_Markers.Markers.Remove(item)
End Sub

Thank you for your great help.

 

Mar 31, 2011 at 4:03 PM

;}

Jul 25, 2013 at 9:02 AM
Hi Guys..

Im a LabVIEW user. I couldn't catch on this statement.

GMapControl1_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker, ByVal e As System.Windows.Forms.MouseEventArgs) Handles GMapControl1.OnMarkerClick
    Layer_Markers.Markers.Remove(item)
End Sub

The OnMarkerClick constructor is under which library/class.
The only that i have as below.
Image

Then what is object object, n what is IntPtr method?
How do i relate with the marker overlay class?

Pls advice.
Jul 25, 2013 at 9:42 AM
i've no idea ;/
Jul 29, 2013 at 10:21 PM
Thanks radioman for your great map.net library.
I'm able use your library in LabVIEW and meet my requirement.
By the way, your latest version for right now is 1.6.0.
In my storage, the library is in version 1.7.0.
May I know, which one is the latest one?
Regarding the routing, can i route the multipoint on the roads without internet connection?
Without the internet con, I got the error on maproute property to genarate the points..
Pls advice.
Thanks.
Jul 30, 2013 at 3:06 PM
routing is done in servers, unless you have your own