Is this possible?

Topics: Help
Apr 30, 2013 at 1:14 PM
Edited Apr 30, 2013 at 1:15 PM
I need to create a route line... around the route line I need to have a larger boundary area.. this boundary area needs to stay a constant size ( Example: 100 feet) so if you zoom out, it should get smaller.

I am using Gmap for Winforms


This is a picture i made in paint.net of what i need.
Image'

Thanks ahead of time for any help!
Apr 30, 2013 at 2:53 PM
Nevermind, figured it out with clipperlib!
May 1, 2013 at 8:10 AM
Could you please share your solution?
May 1, 2013 at 1:41 PM
Xandolph,

The following code is actually for silverlight maps, not GMaps, but it is very similar.

Const Scale As Double = 1000000000.0 'Convert Lat Lng to Int128


'Generate a Polygon from the line string.
        For Each Location In traj.Polyline.Locations
            points.Add(New IntPoint(Location.Longitude * Scale, Location.Latitude * Scale))
        Next

        points.Reverse()
        points.Remove(points.First)


        For Each Location In traj.Polyline.Locations
            points.Add(New IntPoint(Location.Longitude * Scale, Location.Latitude * Scale))
        Next
' This is needed for ClipperLib
        If Clipper.Orientation(points) <> True Then
            points.Reverse()
        End If

        polygons.Add(points)
' First polygon returned is the boundary, following polygons returned are holes in the polygon.
        outpolygon = Clipper.OffsetPolygons(polygons, offset * Scale, JoinType.jtSquare, 100, True)



        Dim first As Boolean = True

        For Each oPoly In outpolygon


            Dim poly As New MapPolygon

            Dim polyColor As Color

            If first Then
                polyColor = Color.FromArgb(45, 0, 200, 20)
            Else
                polyColor = Color.FromArgb(45, 255, 20, 20)
            End If

            Dim polyBrush As New SolidColorBrush(polyColor)

            Dim polyBorder As Color = Colors.White
            Dim polyBorderBrush As New SolidColorBrush(polyBorder)

            poly.Locations = New LocationCollection()
            poly.Stroke = polyBorderBrush
            poly.Opacity = 1.0
            poly.StrokeThickness = 2.0
            poly.Fill = polyBrush

            For Each opoint In oPoly

                Dim lng As Double = opoint.X / Scale
                Dim lat As Double = opoint.Y / Scale

                poly.Locations.Add(New Location(lat, lng))
            Next

            poly.Locations = CollectionExtensions.VertexReduction(poly.Locations, 0.0001) ' Optimization, not needed.

            TrajectoryCoverage.Children.Add(poly) ' Add to overlay.

            first = False
        Next