public void StartUserNavigation() { if (!CurrentUserStatus.CanNavigate) { return; } userNotified = false; Geoposition currentUserPosition = PushpinManager.GetCurrentUserPosition(); IEnumerable <Geoposition> userRoutePositions = RouteManager.GetCurrentUserRoute(); if (userRoutePositions == null || !userRoutePositions.Any()) { return; } // now user has a route and start navigating CurrentUserStatus.AttendingIncidentId = FormsMap.CurrentIncident.Id; CurrentUserStatus.IsNavigating = true; var route = new Route <UserRole>(userRoutePositions.ToArray()); route.Element = null; route.AddStartPoint(currentUserPosition); route.Init(); _routeUpdater.AddRoute(route); }
private async Task RequestAmbulanceOnIncident() { // locate attending incident (can differ from selected) IncidentModel currentIncident = FormsMap.Incidents?.FirstOrDefault(i => i.Id == CurrentUserStatus.AttendingIncidentId); if (currentIncident.IsHighPriority) { // search or create ambulance responder var ambulance = new ResponderModel { Id = 8, ResponderDepartment = DepartmentType.Ambulance, Status = ResponseStatus.EnRoute, Longitude = Settings.AmbulanceLongitude, Latitude = Settings.AmbulanceLatitude, IsPriority = true }; // add responder to map this.PushpinManager.RemoveResponder(ambulance); this.PushpinManager.AddResponders(new List <ResponderModel>() { ambulance }); var fromPosition = new Geoposition() { Latitude = ambulance.Latitude, Longitude = ambulance.Longitude }; var toPosition = new Geoposition() { Latitude = currentIncident.Latitude, Longitude = currentIncident.Longitude }; // create route from ambulance to incident var routeAmbulance = await this.RouteManager.CalculateRoute(fromPosition, toPosition); if (!routeAmbulance.Any()) { // map route service fails routeAmbulance = new[] { fromPosition, toPosition }; } // start route movement var route = new Route <ResponderModel>(routeAmbulance.ToArray()); route.Element = ambulance; route.AddStartPoint(new Geoposition() { Latitude = ambulance.Latitude, Longitude = ambulance.Longitude }); route.Init(); _routeUpdater.AddRoute(route); } }