GMap.NET Custom Image Marker

After using a great Map library over at http://greatmaps.codeplex.com
I required to use a custom image instead of the default ones shipped with the pre-compiled binaries.

Here is what I came up with and works a treat.

Imports System.Drawing
Imports GMap.NET.WindowsForms
Namespace GMap.NET.WindowsForms.Markers

    Public Class GMapCustomImageMarker
        Inherits GMapMarker
        Private _image As Image

        Public Sub New(Image As Image, p As PointLatLng)
            MyBase.New(p)
            _image = Image
        End Sub

        Public Overrides Sub OnRender(g As Graphics)
            g.DrawImage(_image, New Point(LocalPosition.X - _image.Width \ 2, LocalPosition.Y - _image.Height \ 2))
        End Sub
    End Class
End Namespace

Leave a Reply

Your email address will not be published.