Reverse Geocode

The Geocoding API supports looking up places from a set of GPS coordinates (latitude and longitude). This is illustrated in the example below:

@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()
        .ReverseGeocodeAsync(55.71464695218056, 9.531380798128387);

    // 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>

    }

}

Typically the response will contain a number of different results, where a result can be anything from a building, a street address all the way up to the country the coordinates are located in.

For each result, you can use the Types property to check the type of the result - eg. a building would typically have the type point_of_interest, the street address would have the type street_address, and the country would have the type country.