diff --git a/docs/concepts/ArcGISRuntime.md b/docs/concepts/ArcGISRuntime.md index 3fed588..f183df9 100644 --- a/docs/concepts/ArcGISRuntime.md +++ b/docs/concepts/ArcGISRuntime.md @@ -8,47 +8,46 @@ You can also check out the Desktop Sample app in the [Github Repo]( https://gith **Usage:** ```csharp NmeaParser.NmeaDevice device = new NmeaParser.NmeaFileDevice("NmeaSampleData.txt"); -mapView.LocationDisplay.LocationProvider = new NmeaLocationProvider(device); +mapView.LocationDisplay.DataSource = new NmeaLocationProvider(device); +mapView.LocationDisplay.InitialZoomScale = 20000; mapView.LocationDisplay.IsEnabled = true; ``` **NmeaLocationProvider.cs** ```csharp -using System; using System.Threading.Tasks; using Esri.ArcGISRuntime.Geometry; using Esri.ArcGISRuntime.Location; +using NmeaParser; namespace NmeaParser.ArcGIS { - public class NmeaLocationProvider : ILocationProvider + public class NmeaLocationProvider : LocationDataSource { - public event EventHandler LocationChanged; private readonly NmeaParser.NmeaDevice device; public NmeaLocationProvider(NmeaParser.NmeaDevice device) { this.device = device; - device.MessageReceived += device_MessageReceived; + device.MessageReceived += NmeaMessageReceived; } - void device_MessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs e) + private void NmeaMessageReceived(object sender, NmeaMessageReceivedEventArgs e) { var message = e.Message; if (message is NmeaParser.Messages.Rmc rmc && rmc.Active) { - LocationChanged?.Invoke(this, new LocationInfo() - { - Course = double.IsNaN(rmc.Course) ? 0 : rmc.Course, // Current ArcGIS Runtime limitation that course can't be NaN - Speed = double.IsNaN(rmc.Speed) ? 0 : rmc.Speed, - Location = new MapPoint(rmc.Longitude, rmc.Latitude, SpatialReferences.Wgs84) - }); + base.UpdateLocation(new Location( + new MapPoint(rmc.Longitude, rmc.Latitude, SpatialReferences.Wgs84), + horizontalAccuracy: double.NaN, + velocity: double.IsNaN(rmc.Speed) ? 0 : rmc.Speed, + course: double.IsNaN(rmc.Course) ? 0 : rmc.Course, // Current ArcGIS Runtime limitation that course can't be NaN + isLastKnown: false)); } } + protected override Task OnStartAsync() => device.OpenAsync(); - public Task StartAsync() => device.OpenAsync(); - - public Task StopAsync() => device.CloseAsync(); + protected override Task OnStopAsync() => device.CloseAsync(); } }