forked from linguanostra/GoogleMapsAPI.NET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
105 lines (88 loc) · 3.74 KB
/
Copy pathProgram.cs
File metadata and controls
105 lines (88 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
using System;
using System.Collections.Generic;
using GoogleMapsAPI.NET.API.Client;
using GoogleMapsAPI.NET.API.Common.Components.Locations;
using GoogleMapsAPI.NET.API.Common.Components.Locations.Common;
using GoogleMapsAPI.NET.API.Common.Components.Locations.Interfaces;
using GoogleMapsAPI.NET.API.Common.Components.Locations.Interfaces.Combined;
using GoogleMapsAPI.NET.API.Directions.Enums;
using GoogleMapsAPI.NET.API.Places.Enums;
using GoogleMapsAPI.NET.Requests;
namespace GoogleMapsAPI.NET.App
{
/// <summary>
/// Program
/// </summary>
class Program
{
/// <summary>
/// Main entry point
/// </summary>
/// <param name="args">Arguments</param>
static void Main(string[] args)
{
// Get client
var client = new MapsAPIClient("---YOUR API KEY---");
// Get directions
var directions = client.Directions.GetDirections(
new AddressLocation("Chicago,IL"),
new AddressLocation("Los Angeles,CA"),
waypoints: new List<Location>
{
new AddressLocation("Joplin,MO"),
new AddressLocation("Oklahoma City,OK")
});
// Geocode address
var geocode = client.Geocoding.Geocode("203-1200 Saint-Jean-Baptiste, Quebec");
// Search places nearby
var places = client.Places.NearbySearch(
geocode.Results[0].Geometry.Location,
rankBy: PlaceRankByEnum.Distance,
placeType: PlaceSearchTypeEnum.ElectronicsStore);
// Radar search places
var radarPlaces = client.Places.RadarSearch(
geocode.Results[0].Geometry.Location,
10,
placeType: PlaceSearchTypeEnum.ATM);
// Get timezone
var timezone = client.TimeZone.GetTimeZone(35.27801, 149.12958, DateTime.Now);
// Snap to roads
var snap = client.Roads.SnapToRoads(new List<IGeoCoordinatesLocation>()
{
new GeoCoordinatesLocation(35.27801, 149.12958),
new GeoCoordinatesLocation(-35.28032, 149.12907)
});
// Get distance matrix
var matrix = client.DistanceMatrix.GetDistanceMatrix(
new List<IAddressOrGeoCoordinatesLocation>
{
new AddressLocation("Vancouver BC"),
new AddressLocation("Seattle")
},
new List<IAddressOrGeoCoordinatesLocation>
{
new AddressLocation("San Francisco"),
new AddressLocation("Victoria BC")
},
TransportationModeEnum.Bicycling,
language: "fr-FR");
// Get place photo
var resultPhoto = client.Places.GetPlacePhoto(
"CnRtAAAATLZNl354RwP_9UKbQ_5Psy40texXePv4oAlgP4qNEkdIrkyse7rPXYGd9D_Uj1rVsQdWT4oRz4QrYAJNpFX7rzqqMlZw2h2E2y5IKMUZ7ouD_SlcHxYq1yL4KbKUv3qtWgTK0A6QbGh87GB3sscrHRIQiG2RrmU_jF4tENr9wGS_YxoUSSDrYjWmrNfeEHSGSc3FyhNLlBU",
maxWidth: 400);
// Autocomplete
var autoComplete = client.Places.AutoComplete(
"Google",
location: new GeoCoordinatesLocation(-33.86746, 151.207090),
offset: 3,
language: "en-AU",
types: new[] {"geocode"},
components: new ComponentsFilter {["country"] = "au"}
);
// Info
Console.WriteLine();
Console.WriteLine(@"Press ENTER to exit...");
Console.ReadLine();
}
}
}