public async Task LoadRoute() { var positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections( GlobalConfiguration.OriginLatitude, GlobalConfiguration.OriginLongitude, GlobalConfiguration.DestinationLatitude, GlobalConfiguration.DestinationLongitude); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); //Location tracking simulation Device.StartTimer(TimeSpan.FromSeconds(1), () => { if (positions.Count > positionIndex) { UpdatePositionCommand.Execute(positions[positionIndex]); positionIndex++; return(true); } else { return(false); } }); } }
public async Task LoadRoute() { int positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections("18.48849", "-69.971506", "18.5525209", "-69.4376482"); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points)); CalculateRouteCommand.Execute(positions); //Location tracking simulation Device.StartTimer(TimeSpan.FromSeconds(1), () => { if (positions.Count > positionIndex) { UpdatePositionCommand.Execute(positions[positionIndex]); positionIndex++; return(true); } else { return(false); } }); } else { await Application.Current.MainPage.DisplayAlert("No route", "No route found", "Ok"); } }
public async Task LoadRoute() { //var positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections("18.5486875", "-70.2786714", "18.5525209", "-69.4376482"); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); //Location tracking simulation //Device.StartTimer(TimeSpan.FromSeconds(1), () => //{ // if (positions.Count > positionIndex) // { // UpdatePositionCommand.Execute(positions[positionIndex]); // positionIndex++; // return true; // } // else // { // return false; // } //}); } }
public async Task LoadRoute() { var positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections(_originLatitud, _originLongitud, _destinationLatitud, _destinationLongitud); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); HasRouteRunning = true; //Location tracking simulation Device.StartTimer(TimeSpan.FromSeconds(1), () => { if (positions.Count > positionIndex && HasRouteRunning) { UpdatePositionCommand.Execute(positions[positionIndex]); positionIndex++; return(true); } else { return(false); } }); } else { await App.Current.MainPage.DisplayAlert(":(", "No route found", "Ok"); } }
public async Task LoadRoute() { var positionIndex = 1; var googleDirection = await googleMapsApi.GetDirections(_originLatitud.Replace(",", "."), _originLongitud.Replace(",", "."), _destinationLatitud.Replace(",", "."), _destinationLongitud.Replace(",", ".")); if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); HasRouteRunning = true; MyMapa = true; var tempo = googleDirection.Routes[0].Legs[0].Duration.Text; var kms = googleDirection.Routes[0].Legs[0].Distance.Text; MyKms = kms; MyTempo = tempo; //Location tracking simulation //Device.StartTimer(TimeSpan.FromSeconds(1),() => //{ // if(positions.Count>positionIndex && HasRouteRunning) // { // UpdatePositionCommand.Execute(positions[positionIndex]); // positionIndex++; // return true; // } // else // { // return false; // } //}); } else { await Application.Current.MainPage.DisplayAlert(":(", "No route found", "Ok"); } }
public async Task LoadRoute() { var googleDirection = await googleMapsApi.GetDirections(_originLatitud, _originLongitud, _destinationLatitud, _destinationLongitud); /* For Displaying Request and Response on Screen */ await App.Current.MainPage.DisplayAlert("GoogleDirection", "https://maps.googleapis.com/maps/" + Constants.jsoncallstring, "OK"); await App.Current.MainPage.DisplayAlert("GoogleDirection", Constants.jsonstring, "OK"); Constants.jsoncallstring = ""; Constants.jsonstring = ""; if (googleDirection.Routes != null && googleDirection.Routes.Count > 0) { CurrentGoogleDirection = googleDirection; var positions = (Enumerable.ToList(PolylineHelper.Decode(googleDirection.Routes.First().OverviewPolyline.Points))); CalculateRouteCommand.Execute(positions); HasRouteRunning = true; } else { await App.Current.MainPage.DisplayAlert(":(", "No route found", "Ok"); } }
public async Task CalculateRoute(CalculateRouteCommand command) { Console.WriteLine("visiting calculateRoute"); await mediator.Send(command); }