Quantcast
Channel: GMap.NET - Great Maps for Windows Forms & Presentation
Viewing all articles
Browse latest Browse all 3384

New Post: Is this possible?

$
0
0
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

Viewing all articles
Browse latest Browse all 3384


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>