MapWinGIS:SampleCode-VB Net:DrawOnTopOfMap

This is a back-up of the WIKI.
Not all links might work
We're working on a new wiki.

Main Page | Recent changes | View source | Page history | Log in / create account |

Printable version | Disclaimers | Privacy policy

Draw on Top of Map

This snippet demonstrates how to intercept the WM_PAINT event (rather than overriding the OnPaint method, which doesn't work with the map) in order to draw custom content on top of the map using a standard GDI+ Graphics object.

 ' A sublcass of the map that intercepts the paint event, allowing you to draw custom details
 Public Class DrawMap
     Inherits AxMapWinGIS.AxMap
     Private Const WM_PAINT = &HF
     Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
         If m.Msg = WM_PAINT Then
             Dim g As Graphics = Me.CreateGraphics()
             ' Insert your custom drawing here.  Remember this will draw in screen coordinates.
             g.DrawString("Test", New Font("Ariel", 20), Brushes.Black, 200, 200)
         End If
     End Sub
 End Class
 Public Class Form1
     ' This function shows how to add the sub-class map to a form programatically.
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         ' Create a new instance of the subclass
         Dim MyMap As New DrawMap
         ' Force the new map to load on this form, or any other container control by setting the parent property
         MyMap.Parent = Me
         ' Then control the properties that you want.
         MyMap.Dock = DockStyle.Fill
         ' Then use MyMap exactly like you would the AxMap
     End Sub
 End Class

Retrieved from ""

This page has been accessed 1,358 times. This page was last modified on 8 October 2008, at 21:39.