2016-07-06 17 views
-1

erstellen Ich suche nach einer Funktion, die einen Kreis auf der Karte erstellen kann. Ich benutze Gmap Bibliothek in VB.Net. Existieren einige Funktionen, die einen Kreis um einen Punkt auf der Karte erzeugen können, zum Beispiel mit einem Radius von 500 Metern?Wie man Circe mit GMap in VB.Net

fand ich einen Code, aber es ist nicht das, was ich genau bin auf der Suche nach:

Imports System.Drawing 
Imports System.Drawing.Drawing2D 
Imports GMap.NET 
Imports GMap.NET.WindowsForms 

Namespace Map 

    Public Class GMapMarkerCircle 
     Inherits GMapMarker 
     Private m_Radius As Integer 
     'In Meters 
     Public m_OutlinePen As Pen 
     Public m_FillBrush As Brush 
     Public m_Fill As Boolean 

     Public Sub New(p As PointLatLng, Radius As Integer, OutlinePen As Pen, FillBrush As Brush, Fill As Boolean) 
      MyBase.New(p) 
      m_OutlinePen = OutlinePen 
      m_FillBrush = FillBrush 
      m_Radius = Radius 
      m_Fill = Fill 
     End Sub 

     Public Overrides Sub OnRender(g As Graphics) 
      g.SmoothingMode = SmoothingMode.AntiAlias 

      Dim R As Integer = CInt((m_Radius)/Overlay.Control.MapProvider.Projection.GetGroundResolution(Overlay.Control.Zoom, Position.Lat)) * 2 

      If m_Fill = True Then 
       g.FillEllipse(m_FillBrush, New System.Drawing.Rectangle(LocalPosition.X - R \ 2, LocalPosition.Y - R \ 2, R, R)) 
      End If 
      g.DrawEllipse(m_OutlinePen, New System.Drawing.Rectangle(LocalPosition.X - R \ 2, LocalPosition.Y - R \ 2, R, R)) 
     End Sub 

    End Class 
End Namespace 

Und in App:

Dim CircleMarker As New GMapMarkerCircle(New GMap.NET.PointLatLng(ZemSirka, ZemDlzka), 660, New Pen(Color.Azure, 1), Brushes.LightSeaGreen, True) 
      Dim Overlay As New GMapOverlay("Circle") 
      Overlay.Markers.Add(CircleMarker) 
      GMapControl1.Overlays.Add(Overlay) 

Aber als ich heran in der Karte Kreis/out verschwindet. Ich habe eine Anfängerfrage: Gibt es eine Möglichkeit, Pinsel halbtransparent zu machen?

+0

Bürsten halbtransparent, gerade Funktion in der Klasse ändern 'FillBrush Als Brush' zu' FillBrush Als SolidBrush‘und in App-Code von' Brushes.LightSeaGreen' zu 'New SolidBrush (Color.FromArgb (50, Color.BlueViolet)) ' – Oliwer11

Antwort

0

Endlich erstelle ich Code, der für kurze Distanzen gut funktioniert: 200,300,500 Meter.

Public Function toRad(ByVal deegres As Double) 
     Return deegres * (Math.PI/180) 
    End Function 

    Public Function toDeg(ByVal radians As Double) 
     Return radians * (180/Math.PI) 
    End Function 

    Private Function pivotRadius(ByVal Dlzka As Double, ByVal Sirka As Double, ByVal dist As Double) 

     Dim distance = (dist/earthRadius)/1000 
     Dim lat As Double = toRad(Sirka) 
     Dim lng As Double = toRad(Dlzka) 

     Dim points As IList(Of PointLatLng) = New List(Of PointLatLng)() 

     Dim x As Integer = 0 
     While x < 360 
      Dim brng As Double = toRad(x) 
      Dim latRadians As Double = Math.Asin(Math.Sin(lat) * Math.Cos(distance) + Math.Cos(lat) * Math.Sin(distance) * Math.Cos(brng)) 
      Dim lngRadians As Double = lng + (Math.Atan2(Math.Sin(brng) * Math.Sin(distance) * Math.Cos(lat), Math.Cos(distance) - Math.Sin(lat) * Math.Sin(latRadians))/1.6) 
      points.Add(New PointLatLng(toDeg(lngRadians), toDeg(latRadians))) 
      latRadians = 0 
      lngRadians = 0 
      x += 10 
     End While 

     Dim polyOverlay As New GMapOverlay("polygons") 
     Dim polygon As New GMapPolygon(points, "mypolygon") 
     polygon.Fill = New SolidBrush(Color.FromArgb(30, Color.Aqua)) 
     polygon.Stroke = New Pen(Color.Blue, 1) 
     GMapControl1.Overlays.Clear() 
     GMapControl1.Overlays.Add(polyOverlay) 
     polyOverlay.Polygons.Add(polygon) 

     Return 0 

    End Function