static void Main(string[] args) { Console.WriteLine("Starting"); Random r = new Random(); Random e = new Random(); MapsAPI maps = new MapsAPI(); // r.Next(Order.Places.Count-1) Order balls = new Order(Order.SomePlaces[r.Next( Order.SomePlaces.Count - 1)], Order.OtherPlaces[e.Next(Order.OtherPlaces.Count - 1)], 4); Thread.Sleep(500); Order paddle = new Order(Order.SomePlaces[r.Next( Order.SomePlaces.Count )], Order.OtherPlaces[e.Next(Order.OtherPlaces.Count)], 4, 2); Order paddles = new Order(Order.SomePlaces[r.Next(Order.SomePlaces.Count )], Order.OtherPlaces[e.Next( Order.OtherPlaces.Count)], 30); maps.goToPlace(paddle.Destination); Console.WriteLine($"Origin: {paddle.Origin} \tDestination: {paddle.Destination}\tDist: {paddle.Distance} Price:{paddle.Price}" ); Console.WriteLine($"Origin: {paddles.Origin}\t Destination: {paddles.Destination}\tDist: {paddles.Distance}\t Price:{paddles.Price}"); Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Starting"); Random r = new Random(); Random e = new Random(); MapsAPI maps = new MapsAPI(); // r.Next(Order.Places.Count-1) Order balls = new Order("paddy+lane+ontario+ny", "Cincinnati", 5); Order paddle = new Order(Order.SomePlaces[r.Next(Order.SomePlaces.Count - 1)], Order.OtherPlaces[e.Next(Order.OtherPlaces.Count - 1)], 4); Console.WriteLine($"Origin: {paddle.Origin} \tDestination: {paddle.Destination}\tDist: {paddle.Distance} Price:{paddle.Price}"); Console.WriteLine($"Origin: {balls.Origin}\t Destination: {balls.Destination}\tDist: {balls.Distance}\t Price:{balls.Price}"); Console.ReadKey(); }
static void Main(string[] args) { //Static class use (Directions) DirectionsRequest directionsRequest = new DirectionsRequest() { Origin = "NYC, 5th and 39", Destination = "Philladephia, Chesnut and Wallnut", }; DirectionsResponse directions = MapsAPI.GetDirections(directionsRequest); Console.WriteLine(directions); //Instance class use (Geocode) GeocodingRequest geocodeRequest = new GeocodingRequest() { Address = "new york city", }; GeocodingEngine geocodingEngine = new GeocodingEngine(); GeocodingResponse geocode = geocodingEngine.GetGeocode(geocodeRequest); Console.WriteLine(geocode); // Static maps API - get static map of with the path of the directions request StaticMapsEngine staticMapGenerator = new StaticMapsEngine(); //Path from previos directions request IEnumerable <Step> steps = directions.Routes.First().Legs.First().Steps; // All start locations IList <ILocation> path = steps.Select(step => step.StartLocation).ToList <ILocation>(); // also the end location of the last step path.Add(steps.Last().EndLocation); string url = staticMapGenerator.GenerateStaticMapURL(new StaticMapRequest(new Location(40.38742, -74.55366), 9, new ImageSize(800, 400)) { Pathes = new List <Path>() { new Path() { Style = new PathStyle() { Color = "red" }, Locations = path } } }); Console.WriteLine("Map with path: " + url); //Instance class - Async! (Elevation) ElevationRequest elevationRequest = new ElevationRequest() { Locations = new Location[] { new Location(54, 78) }, }; ElevationEngine elevationEngine = new ElevationEngine(); elevationEngine.BeginGetElevation(elevationRequest, ar => { ElevationResponse elevation = elevationEngine.EndGetElevation(ar); Console.WriteLine(elevation); }, null); Console.WriteLine("Finised! (But wait .. async elevation request should get response soon)"); Console.ReadKey(); }
public Location[] GetLocationInfo(LatLong location, string dataSourceName, GetInfoOptions options) { var response = MapsAPI.GetGeocode( new GeocodingRequest { Location = new GoogleMapsApi.Entities.Common.Location(location.Latitude, location.Longitude), Language = "pl" }); if (response.Status != Status.OK) { throw new Exception(response.Status.ToString()); } Thread.Sleep(250); FindHeader.Original = JsonConvert.SerializeObject( response.Results .GroupBy(r => string.Join(", ", r.Types)) .ToDictionary( rg => rg.Key, rg => rg.Select( r => r.AddressComponents .GroupBy(c => string.Join(", ", c.Types)) .ToDictionary( cg => cg.Key, cg => cg.Select( c => string.Format("{0} ({1})", c.ShortName, c.LongName) ) ) ) ), Formatting.Indented); Debug.WriteLine(FindHeader.Original); var country = response.Results.GetType("country"); var admin1 = response.Results.GetType("administrative_area_level_1"); var admin2 = response.Results.GetType("administrative_area_level_2"); var admin3 = response.Results.GetType("administrative_area_level_3"); var neighborhood = response.Results.GetType("neighborhood"); var street = response.Results.GetType("street_address"); var route = response.Results.GetType("route"); // ReSharper disable ConstantNullCoalescingCondition var result = new Location { Entity = new Entity { DisplayName = "", }, Address = new Address { CountryRegion = null ?? country.GetComponent("country") ?? street.GetComponent("country") ?? route.GetComponent("country"), Subdivision = null ?? admin1.GetComponent("administrative_area_level_1") ?? street.GetComponent("administrative_area_level_1") ?? route.GetComponent("administrative_area_level_1"), PrimaryCity = null ?? street.GetComponent("locality") ?? route.GetComponent("locality"), AddressLine = new[] { null ?? street.GetComponent("route") ?? route.GetComponent("route"), null ?? street.GetComponent("sublocality") ?? route.GetComponent("sublocality") ?? neighborhood.GetComponent("sublocality") ?? admin3.GetComponent("administrative_area_level_3") }.JoinNotEmpty(", "), FormattedAddress = null ?? street.GetComponent("formatted_address") ?? route.GetComponent("formatted_address") } }; // ReSharper restore ConstantNullCoalescingCondition if (result.Address.Subdivision == null) { result.Address.Subdivision = result.Address.CountryRegion; } return(new[] { result }); }