示例#1
0
 private void LocationProvider_LocationChanged(object?sender, Esri.ArcGISRuntime.Location.Location e)
 {
     Dispatcher.BeginInvoke((Action) delegate()
     {
         //Zoom in on first location fix
         mapView.LocationDisplay.DataSource.LocationChanged -= LocationProvider_LocationChanged;
         mapView.SetViewpointCenterAsync(e.Position, 5000);
         mapView.LocationDisplay.AutoPanMode = Esri.ArcGISRuntime.UI.LocationDisplayAutoPanMode.Navigation;
     });
 }
示例#2
0
        private void LocationDisplay_LocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e)
        {
            // Return if no location.
            if (e.Position == null)
            {
                return;
            }

            // Unsubscribe; only want to zoom to location once.
            ((LocationDisplay)sender).LocationChanged -= LocationDisplay_LocationChanged;
            RunOnUiThread(() => { _myMapView.SetViewpoint(new Viewpoint(e.Position, 10000)); });
        }
示例#3
0
        private void LocationDisplay_LocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e)
        {
            // Return if position is null; event is raised with null location after.
            if (e.Position == null)
            {
                return;
            }

            // Unsubscribe from further events; only want to zoom to location once.
            ((LocationDisplay)sender).LocationChanged -= LocationDisplay_LocationChanged;

            // Need to use this to interact with UI elements because this function is called from a background thread.
            InvokeOnMainThread(() => _myMapView.SetViewpoint(new Viewpoint(e.Position, 100000)));
        }
        private void LocationDisplay_LocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e)
        {
            // Return if position is null; event is called with null position when location display is turned on
            if (e.Position == null) { return; }

            // Unsubscribe to the event (only want to zoom once)
            ((LocationDisplay)sender).LocationChanged -= LocationDisplay_LocationChanged;

            // Needed because the event is called from a background thread, but the code is manipulating UI
            Dispatcher.Invoke(() =>
            {
                // Zoom to the location
                MyMapView.SetViewpointAsync(new Viewpoint(e.Position, 100000));
            });
        }
示例#5
0
        private async void LocationDisplay_LocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e)
        {
            // Return if position is null; event is raised with null location after
            if (e.Position == null)
            {
                return;
            }

            // Unsubscribe from further events; only want to zoom to location once
            ((LocationDisplay)sender).LocationChanged -= LocationDisplay_LocationChanged;

            // Need to use the dispatcher to interact with UI elements because this function is called from a background thread
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                MyMapView.SetViewpoint(new Viewpoint(e.Position, 100000));
            });
        }
        private void LocationDataSourceOnLocationChanged(object sender, Esri.ArcGISRuntime.Location.Location e)
        {
            // Add any previous position to the history
            if (_lastPosition != null)
            {
                try
                {
                    _locationHistoryOverlay.Graphics.Add(new Graphic(_lastPosition));
                }
                catch
                {
                    _fakeLocationDataSource.LocationChanged -= LocationDataSourceOnLocationChanged;
                }
            }

            // Store the current position
            _lastPosition = e.Position;
        }
示例#7
0
        private void OnLocationChanged(object sender, EventArgs e)
        {
            if (double.IsNaN(m_gnssMonitor.Longitude) || double.IsNaN(m_gnssMonitor.Latitude))
            {
                return;
            }
            if (!double.IsNaN(m_gnssMonitor.Course))
            {
                lastCourse = m_gnssMonitor.Course;
            }
            DateTimeOffset?timestamp = null;

            if (m_gnssMonitor.FixTime.HasValue)
            {
                timestamp = new DateTimeOffset(DateTime.UtcNow.Date.Add(m_gnssMonitor.FixTime.Value));
            }
            var location = new Esri.ArcGISRuntime.Location.Location(
                timestamp: timestamp,
                position: !double.IsNaN(m_gnssMonitor.Altitude) ? new MapPoint(m_gnssMonitor.Longitude, m_gnssMonitor.Latitude, m_gnssMonitor.Altitude, wgs84_ellipsoidHeight) : new MapPoint(m_gnssMonitor.Longitude, m_gnssMonitor.Latitude, SpatialReferences.Wgs84),
                horizontalAccuracy: m_gnssMonitor.HorizontalError,
                verticalAccuracy: m_gnssMonitor.VerticalError,
                velocity: double.IsNaN(m_gnssMonitor.Speed) ? 0 : m_gnssMonitor.Speed * 0.51444444,
                course: lastCourse,
                !m_gnssMonitor.IsFixValid);

            // Avoid raising additional location events if nothing changed
            if (currentLocation == null ||
                currentLocation.Position.X != location.Position.X ||
                currentLocation.Position.Y != location.Position.Y ||
                currentLocation.Position.Z != location.Position.Z ||
                currentLocation.Course != location.Course ||
                currentLocation.Velocity != location.Velocity ||
                currentLocation.HorizontalAccuracy != location.HorizontalAccuracy ||
                currentLocation.VerticalAccuracy != location.VerticalAccuracy ||
                currentLocation.IsLastKnown != location.IsLastKnown ||
                timestamp != location.Timestamp)
            {
                currentLocation = location;
                UpdateLocation(currentLocation);
            }
        }