private void ActivateNextWaypoint() { _distanceWalkedMiles += GetLastWayPoint().Distance(NextWaypoint); VisitedWaypoints.Add(RouteEnumerator.Current); if (!RouteEnumerator.MoveNext()) { OnNavigationFinished(); } NextWaypoint = RouteEnumerator.Current; }
public async Task <bool> StartNavigation() { var locationPermission = DependencyService.Get <ILocationPermission>(); var permissionGranted = await locationPermission.CheckAndAsk(); GeoPosition position = null; try { position = (await _geoLocator.GetPositionAsync()).ToGeoPosition(); } catch (GeolocationException e) { var properties = new Dictionary <string, string> { { "Permission status", permissionGranted.ToString() } }; Crashes.TrackError(e, properties); return(false); } if (_route.GetSectionForPosition(position) == RouteExtensions.DefaultSection) { Application.Current.MainPage = new NotNearRoutePage(); return(false); } NextWaypoint = _route.FindClosestWaypoint(position); VisitedWaypoints = new List <RoutePoint> { NextWaypoint }; var section = _route.GetSectionForPosition(NextWaypoint); NavigationDirection = _route.DetermineLongestDirectionInSection(NextWaypoint, section); RouteEnumerator = _route.GetEnumerable(NextWaypoint, NavigationDirection).GetEnumerator(); RouteEnumerator.MoveNext(); ActivateNextWaypoint(); InitializeMap(position); await StartListeningToLocationAsync(); return(true); }