Public Class GpsTool Private gpsLayer As GpsLayer Private _locationWatcher As IGeoPositionWatcher(Of Geocoordinate) Private _isStarted As Boolean 'in sub New() Public Sub New(map As Map) gpsLayer = New GpsLayer() 'when button is pressed for gps-on Private Sub gpsButtonClick... _isStarted = True ThreadPool.QueueUserWorkItem(DirectCast(Sub() CreateGpsWatcher(ESRI.ArcGIS.Client.Local.Gps.SerialPortGpsCoordinateWatcher.FindEnabledPort(1)), WaitCallback)) Private Sub CreateGpsWatcher(serialPorts as List(Of String)) 'dispatcher code 'if device found _locationWatcher = New ESRI.ArcGIS.Client.Local.Gps.SerialPortGpsCoordinateWatcher() With { .portName = serialPorts(0) _ } 'geometry service for projections gpsLayer.GeoPositionWatcher = _locationWatcher gpsLayer.GeoPositionWatcher.Start() AddHandler gpsLayer.PositionChanged, AddressOf gpsPosition_Changed 'Then in gpsPosition_Changed - this is where I am accessing the properties of the gpsLayer, such as: Private Sub gpsPosition_Changed(sender As Object, args As EventArgs) Console.WriteLine(gpsLayer.GeoCoordinate.Altitude.ToString)
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.