Test for type of marker

May 24, 2010 at 9:34 PM

Is there a way to test what type of marker I've clicked on?  GMapMarkerGoogleGreen, etc.

Dennis.

Coordinator
May 24, 2010 at 9:42 PM

MainMap.OnMarkerClick += new MarkerClick(MainMap_OnMarkerClick);

May 25, 2010 at 4:51 PM
Edited May 25, 2010 at 4:53 PM

At the moment if I click a Marker I can get it's Position, or I can remove it, etc.., but I want to know what type of Marker it is.  Is it a Red Google Marker or a Green Marker or what.

Dennis.

Coordinator
May 25, 2010 at 5:37 PM
Edited May 25, 2010 at 5:39 PM

why don't you just look how demos are constructed ;} 

 // click on some marker
 void MainMap_OnMarkerClick(GMapMarker item)
 { 
   if(item is GMapMarkerRect)
   { ...
May 25, 2010 at 6:36 PM

Sorry, I'm sure I tried that and just got an error, but I might have not!  After a while of trying different things I loose track of what I have tried!

Thanks.

May 25, 2010 at 7:38 PM

No, I get an error.  "GMapMarkerGoogleGreen is a type and cannot be used in an expression"

This is my code:

Private Sub MyMap_OnMarkerClick(ByVal item As GMap.NET.WindowsForms.GMapMarker) Handles MyMap.OnMarkerClick
    If (item = GMapMarkerGoogleGreen) Then
         Layer_Markers.Markers.Remove(item)
    End If
End Sub
Sorry, I feel I'm being stupid here but........
TIA,
Dennis

 

Coordinator
May 25, 2010 at 8:07 PM

it's very easy to use reflector and set language to VB.NET, and you get:

Private Sub MainMap_OnMarkerClick(ByVal item As GMapMarker)
    If TypeOf item Is GMapMarkerRect Then
    ...
    End If
End Sub
May 25, 2010 at 8:17 PM

Ahhh!  I didn't know "Typeof".  Must look that one up.  Thanks.

Dennis.