Custom Routes like Markers

Topics: Windows Forms
Jun 13, 2011 at 8:41 AM

Hello Radioman,

actually i add a filled polygon like this:

        Dim myRoute As New GMapRoute(polygonPoints, "myRoute")

        Dim myTestPolygon As GMapOverlay

        myTestPolygon = New GMapOverlay(Form_Main.MainMap, "Test")
        myTestPolygon.IsFillRouteAsPolygon = True
        myTestPolygon.StrokeLine = New Pen(Color.FromArgb(255, myColor), 2)
        myTestPolygon.FillBrush = New SolidBrush(Color.FromArgb(100, myColor))


But i think this is not the best way. Would it be possible to create a custom route class?

So you can add polygons on layers and i think the handling is easier?

Thanks for discussion.


Jun 13, 2011 at 8:54 AM

just use myTestPolygon.Polygons.Add(...

p.s. yes you can customize every class: overlay, marker, route, etc

Jun 14, 2011 at 8:50 AM

I can not :)

My wish is to create a own CustomPolygon or CustomRoute class. (Well i just want a filled polygon, with some additional properties like ID, Name, sth..)

Imports System.Collections.Generic
Imports System.Text
Imports System.Drawing
Imports GMap.NET.WindowsForms
Imports GMap.NET

Public Class CustomPolygon
    Inherits GMapPolygon
    Public Pen As Pen
    Public FillBrush As Brush
    Public ID As Integer
    Public Type as String
    Public isFilled As Boolean

    Public Sub New(ByVal points As List(Of PointLatLng), ByVal name As String)
        MyBase.New(points, name)

        Pen = New Pen(Brushes.Red, 5)
    End Sub
End Class

To add Polygon:

        Dim myCustomPolygon As New CustomPolygon(polygonPoints, "blubb")
        myCustomPolygon.Pen = New Pen(Color.FromArgb(255, myColor), myView.PolygonStrokeThickness)
        myCustomPolygon.FillBrush = New SolidBrush(Color.FromArgb(100, myColor))

If i just use this, the Polygon is painted, but with the colors of your Polygon. I have no possibilty to override id on painting. Could you help me? pls^^

Jun 14, 2011 at 9:44 AM

just override render function

Jun 14, 2011 at 11:06 AM

The method OnRender does not exists.

Jun 14, 2011 at 12:04 PM

check GMapOverlay class