Custom marker using WinForms VS2010 VB

Topics: Windows Forms
Jul 25, 2011 at 7:48 PM

Hi everybody. Greetings to Radioman!

Im wonder if any person here have a sample of how to put some markers, and make that markers "customized" with different bitmaps/icons. Im trying to develop a small windows forms app, under Visual Basic (Visual Studio 2010)

Thanks in advance. And kudos to Radioman for this cool project.

Jul 26, 2011 at 9:24 PM

I figured out how to make a custom marker, also i figured how to "activate" the tooltips again. Only i have one doubt. How i can change in the fly the bitmap of the marker without removing and adding again the marker?

greetings Radioman.

Jul 26, 2011 at 9:30 PM

update the image, call map.Invalidate()

Jul 26, 2011 at 10:23 PM

I have this:

    Public Class GMapMarker_Custom
        Inherits GMapMarker

        Dim _image As System.Drawing.Image
        Dim _point As PointLatLng

        Sub New(ByVal iPoint As PointLatLng, ByVal discipline As String)
            MyBase.New(iPoint)
            _point = iPoint
            Select Case discipline
                Case "CarroVerde"
                    _image = My.Resources.CarFamGreen
                Case "CarroAmarillo"
                    _image = My.Resources.CarFamYellow
                Case "CarroRojo"
                    _image = My.Resources.CarFamRed
                Case "CarroNegro"
                    _image = My.Resources.CarFamBlack
            End Select
        End Sub

        Public Overloads Overrides Sub OnRender(ByVal g As Graphics)
            Dim p As New System.Drawing.Point(_point.Lat, _point.Lng)
            MyBase.OnRender(g)
            g.DrawImageUnscaled(_image, System.Convert.ToInt32(LocalPosition.X), System.Convert.ToInt32(LocalPosition.Y))
        End Sub
    End Class

 

Im using in this way:

private sub blahblahblah

        Dim ArrayMarkers(1) As GMapMarker

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

        ArrayMarkers(1) = New GMapMarker_Custom(New PointLatLng(10.14, -67.44), "CarroAmarillo")
        ArrayMarkers(1).Size = New Drawing.Size(My.Resources.CarFamGreen.Size.Width, My.Resources.CarFamGreen.Size.Height)
        ArrayMarkers(1).Offset = New Drawing.Point(-(My.Resources.CarFamGreen.Size.Width / 2), -My.Resources.CarFamGreen.Size.Height)

        Layer_Markers.Markers.Add(ArrayMarkers(1))

end sub

 

I tried:

 ArrayMarkers(1) = New GMapMarker_Custom(New PointLatLng(10.14, -67.44), "CarroNegro")

 GMapControl.Invalidate()

but nothing.

 

How accomplish the change of bitmap? im running out of ideas. Sorry radioman.  :'(

Jul 28, 2011 at 12:01 AM

Im figured out how to switch between different custom markers. I will post my final code, to help others developers in VB to make markers. Thanks anyway radioman for this cool project!