GMap.NET Custom Image Marker

Table of Contents

After using a great Map library
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

Our Services