Blog

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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

Posted in: Technical

Leave a Comment (0) ↓

Leave a Comment