private async void OnPanToUserLocationWhenLocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e) { if (_mapView.LocationDisplay.MapLocation.X != 0.0 || _mapView.LocationDisplay.MapLocation.Y != 0.0) { _mapView.LocationDisplay.LocationChanged -= OnPanToUserLocationWhenLocationChanged; await PanToUserLocation(); } }
protected virtual void OnMessageReceived(object sender, NmeaParser.NmeaMessageReceivedEventArgs args) { const double knotsToMeterPerSecond = 0.5144; try { double?latitude = null; double?longitude = null; switch (args.Message) { case NmeaParser.Messages.Gga gga: TrackedSatelliteCount = gga.NumberOfSatellites; // Satellites being tracked // gga.Hdop // Horizontal dilution of position if (gga.Quality != NmeaParser.Messages.Gga.FixQuality.Invalid) { latitude = gga.Latitude; longitude = gga.Longitude; } break; case NmeaParser.Messages.Gsa gsa: TrackedSatelliteCount = (gsa.SatelliteIDs?.Count() ?? 0); // Satellite IDs used for fix // gsa.Fix // None; 2D; or, 3D // gsa.Pdop // gsa.Hdop // gsa.Vdop break; case NmeaParser.Messages.Rma rma: if (rma.Status != NmeaParser.Messages.Rma.PositioningStatus.Invalid) { latitude = rma.Latitude; longitude = rma.Longitude; if (!double.IsNaN(rma.Course)) { Course = rma.Course; } Velocity = (rma.Speed * knotsToMeterPerSecond); } break; case NmeaParser.Messages.Rmc rmc: latitude = rmc.Latitude; longitude = rmc.Longitude; if (!double.IsNaN(rmc.Course)) { Course = rmc.Course; } Velocity = (rmc.Speed * knotsToMeterPerSecond); break; } var validLatitude = ((latitude != null) && (!double.IsNaN(latitude.Value))); var validLongitude = ((longitude != null) && (!double.IsNaN(longitude.Value))); if (validLatitude && validLongitude) { var mapPoint = new MapPoint(longitude.Value, latitude.Value, SpatialReferences.Wgs84); var location = new Esri.ArcGISRuntime.Location.Location(mapPoint, 2, Velocity, Course, false); UpdateLocation(location); } } catch (Exception ex) { } }
private void InputLocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e) { // Update the tracker location with the new location from the source (simulation or GPS). _routeTracker.TrackLocationAsync(e); }