106 lines
3.8 KiB
VB.net
106 lines
3.8 KiB
VB.net
Imports DevExpress.XtraMap
|
|
Imports DevExpress.XtraGrid
|
|
|
|
Public Class frmGeodataNavigation
|
|
|
|
Private BING_KEY As String = "hQUTlqLLK70bETnonpfi~0jx1pIAq1yQ7gXqbIyzKrg~Au-Tewbty8afAxdbNilSv4JlU7qwU-fQKu0ouH9e1uJmpIyVdA3jugVEWMdy1Rbt"
|
|
Private EntityId As Integer = Nothing
|
|
Private EntitySql As String = Nothing
|
|
Private Grid As GridControl = Nothing
|
|
|
|
Private ReadOnly Property ImageLayer() As ImageTilesLayer
|
|
Get
|
|
Return CType(MapControl1.Layers("ImageLayer"), ImageTilesLayer)
|
|
End Get
|
|
End Property
|
|
|
|
Private ReadOnly Property VectorLayer() As VectorItemsLayer
|
|
Get
|
|
Return CType(MapControl1.Layers("VectorLayer"), VectorItemsLayer)
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub New(ByRef gridControl As GridControl, ByVal EntityId As Integer)
|
|
' Dieser Aufruf ist für den Designer erforderlich.
|
|
InitializeComponent()
|
|
|
|
' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
|
|
Me.Grid = gridControl
|
|
Me.EntityId = EntityId
|
|
Me.EntitySql = String.Format("SELECT T.*, T1.LATITUDE, T1.LONGITUDE from VWTEMP_PMO_FORM{0} T,TBPMO_RECORD_GEODATA T1 WHERE T.[Record-ID] = T1.RECORD_ID", Me.EntityId)
|
|
End Sub
|
|
|
|
Private Sub frmGeodataNavigation_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
' Liste für PushPins anlegen
|
|
Dim items As New List(Of MapPushpin)
|
|
|
|
' Kartendaten laden
|
|
Dim dataProvider As New BingMapDataProvider()
|
|
dataProvider.BingKey = BING_KEY
|
|
ImageLayer.DataProvider = dataProvider
|
|
|
|
' Datensätze mit Lat,Lon Werten laden
|
|
Dim dt As DataTable = ClassDatabase.Return_Datatable(Me.EntitySql)
|
|
|
|
' PushPins
|
|
For Each row As DataRow In dt.Rows
|
|
Dim lat As Double = row.Item("LATITUDE")
|
|
Dim lon As Double = row.Item("LONGITUDE")
|
|
Dim pushpin As New MapPushpin()
|
|
pushpin.Location = New GeoPoint(lat, lon)
|
|
pushpin.Text = row.Item("Record-ID").ToString()
|
|
pushpin.Information = row.Item("Record-ID")
|
|
|
|
items.Add(pushpin)
|
|
Next
|
|
|
|
Dim storage As New MapItemStorage()
|
|
Dim itemArray() As MapPushpin = items.ToArray()
|
|
|
|
storage.Items.AddRange(itemArray)
|
|
VectorLayer.Data = storage
|
|
|
|
tsLabelRecordCount.Text = String.Format("{0} Elemente gefunden", items.Count)
|
|
|
|
MapControl1.ZoomToFitLayerItems()
|
|
End Sub
|
|
|
|
Private Sub SetGridFilter(records As List(Of Integer))
|
|
Dim filter As New List(Of String)
|
|
|
|
For Each id As Integer In records
|
|
filter.Add(String.Format("[Record-Id] = {0}", id))
|
|
Next
|
|
|
|
Dim gridView As Views.Grid.GridView = Me.Grid.FocusedView
|
|
gridView.ActiveFilterString = String.Join(" OR ", filter.ToArray())
|
|
End Sub
|
|
|
|
'Private Sub MapControl1_MapItemClick(sender As Object, e As MapItemClickEventArgs) Handles MapControl1.MapItemClick
|
|
|
|
'End Sub
|
|
|
|
'Private Sub MapControl1_MapItemDoubleClick(sender As Object, e As MapItemClickEventArgs) Handles MapControl1.MapItemDoubleClick
|
|
' Dim item As MapPushpin = e.Item
|
|
' Dim recordId As Integer = item.Information
|
|
|
|
' SetGridFilter(New List(Of Integer) From {recordId})
|
|
'End Sub
|
|
|
|
Private Sub MapControl1_SelectionChanged(sender As Object, e As MapSelectionChangedEventArgs) Handles MapControl1.SelectionChanged
|
|
Dim items As List(Of Object) = e.Selection
|
|
Dim records As New List(Of Integer)
|
|
|
|
For Each item As Object In items
|
|
Try
|
|
Dim pin As MapPushpin = CType(item, MapPushpin)
|
|
Dim recordId As Integer = pin.Information
|
|
records.Add(recordId)
|
|
Catch ex As Exception
|
|
MsgBox("Cannot convert selection to MapPushPin")
|
|
End Try
|
|
Next
|
|
|
|
SetGridFilter(records)
|
|
End Sub
|
|
End Class |