/// <summary> /// Gets the directions poly line. /// </summary> /// <returns>The directions poly line.</returns> /// <param name="startCoordinate">Start coordinate.</param> /// <param name="destinationCoordinate">Destination coordinate.</param> /// <param name="mode">Mode.</param> public IObservable <GoogleGeocodeContract> GetDirectionsPolyLine(GeoCoordinate startCoordinate, GeoCoordinate destinationCoordinate, GoogleMapsTravelModes mode) { var startLatString = startCoordinate.Latitude.ToString().Replace(',', '.'); var startLongString = startCoordinate.Longitude.ToString().Replace(',', '.'); var destLatString = destinationCoordinate.Latitude.ToString().Replace(',', '.'); var destLongString = destinationCoordinate.Longitude.ToString().Replace(',', '.'); var startString = startLatString + "," + startLongString; var destinationString = destLatString + "," + destLongString; string param = string.Format(Config.DirectionParamsUrl, startString, destinationString, Config.GoogleApiKey); param += string.Format("&mode={0}", mode.ToString().ToLower()); var directionsUrl = string.Format("/{0}", Config.DirectionsUrl + param); return(SendInternal <GoogleGeocodeContract>(directionsUrl, string.Empty, HttpMethod.Get)); }
/// <summary> /// Creates the path async. /// </summary> /// <returns>The path async.</returns> public IObservable <Unit> CreatePathAsync(GoogleMapsTravelModes travelMode) { IsLoading = true; IsError = false; _currentTravelMode = travelMode; var startCoordinate = new GeoCoordinate(CurrentLocation.Latitude, CurrentLocation.Longitude); return(GoogleMapsWebServiceController .GetDirectionsPolyLine(startCoordinate, _endCoordinate, _currentTravelMode) .ObserveOn(this.Scheduler) .Catch <GoogleGeocodeContract, Exception>(error => { DidException(error, "Select failed using call to web service GetEReactiveUIAroundMeById"); return Observable.Empty <GoogleGeocodeContract>(); }) .Do(geocode => { IsLoading = false; var routes = geocode.Routes; var route = routes?.Length > 0 ? routes[0] : null; if (route != null) { var polyline = route.Bounds; var path = CreatePath(route.OverviewPolyline.Points); // update new path PathUpdate?.Invoke(this, new PathUpdateEventArgs() { StartCoordinate = startCoordinate, EndCoordinate = _endCoordinate, Path = path, }); } }).Select(x => Unit.Default)); }