Skip to content
EvaldasBend edited this page Mar 6, 2016 · 3 revisions

The Google Places API allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place;

Example

In this case we are looking for city called Batilly.

TextSearchRequest request = new TextSearchRequest()
{
   Query = "Batilly",
   Sensor = false
};

The 'PlacesService' class submits the request to the API web service. We save the first result. If you would be querying something like cafe, or shop, you woulde get multiple results in this case there is only one city called Batilly.

var service = new PlacesService().GetResponse(request);
var results = service.Results.First();

After that we print some results:

Console.WriteLine("Formated Address: {0}", results.FormattedAddress);
Console.WriteLine("Object Name: {0}", results.Name);
Console.WriteLine("Coordinates: {0}", results.Geometry.Location);

Output:
Formated Address: Batilly, France
Object Name: Batilly
Coordinates: 49.171020,5.969358

Clone this wiki locally