Get a place by its ID

If you already have the ID of a place, you can use the GetPlace method or the async GetPlaceAsync method to get details about the place.

@using Skybrud.Social.Google.Geocoding
@using Skybrud.Social.Google.Geocoding.Models
@using Skybrud.Social.Google.Geocoding.Responses
@inherits Microsoft.AspNetCore.Mvc.Razor.RazorPage<Skybrud.Social.Google.GoogleHttpService>

@{

    // Make the request to the Geocoding API
    GeocodingResultListResponse response = await Model
        .Geocoding()
        .GetPlaceAsync("ChIJhTohbU-CTEYRbJ5l2nNQic4");

    // Iterate through the result
    foreach (GeocodingResult result in response.Body.Results) {

        <p>
            <strong>@result.PlaceId</strong><br />
            @result.FormattedAddress <small>(@string.Join(", ", result.Types))</small>
        </p>

    }

}

If successful, the response body will be an instance of GeocodingResultList, which then will hold a single GeocodingResult.

It's worth mentioning that an ID in the Geocoding API is interchangable with an ID in the Google Places API, which will have more information about each place - e.g. the name of a place and various business information if the place is a business.