Use Places APIs and Geocoding with data-driven styling for boundaries

Select platform: Android iOS JavaScript

You can use the Places SDK for iOS and the Geocoding API with the Maps SDK for iOS to search for regions, and get more information about places. The Places SDK for iOS and Geocoding API are powerful and stable alternatives for obtaining place IDs. If you're already using place IDs, you can reuse those IDs with data-driven styling for boundaries.

Add Places and Geocoding to your Maps SDK for iOS apps in the following ways:

  • Places SDK for iOS returns information about places using HTTP requests.
  • CLGeocoder class can geocode and reverse geocode dynamically from user input.
  • Geocoding API lets you geocode static, known addresses.

Use the Places API

  • The Places API Text Search returns information about a set of places based on a string — for example "pizza in New York" or "shoe stores near Ottawa" or "123 Main Street". The service responds with a list of places matching the text string and any location bias that has been set.

  • The Places Autocomplete service provides a convenient way to let your users search for regions. To display results within the defined region, set locationRestriction on GMSAutocompleteFilter.

Get place details for a region

  • The Place Details data for a region is also effective. For example, you can:

    • Search for boundary place IDs based on place names.
    • Get the viewport for zooming to a boundary.
    • Get the feature type for the boundary (for example locality).
    • Get the formatted address, which resolves to "Place Name, State, Country" in the United States region (for example, "Kirkland, WA, USA").
    • Get other useful data such as photos.

Use the Geocoding API

  • The Geocoding API lets you convert an address, latitude and longitude coordinates, or place ID into geographic coordinates, and vice-versa. The following uses combine well with data-driven styling for boundaries:

    • Use Geocoding to get the viewport for a region.
    • Apply component filtering to your Geocoding call to get the place IDs for administrative areas 1-4, locality, or postal code.
    • Use reverse geocoding to find place IDs by latitude and longitude coordinates, or even return place IDs for all components in a particular location.

    The following example uses an address (url-escaped) to make a request to the Geocoding API:

    https://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&key=YOUR_API_KEY
    

    You can use reverse geocoding to find place IDs. The following example Geocoding service function returns the place IDs for all address components at the specified latitude and longitude coordinates:

    https://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&result_type=locality&key=YOUR_API_KEY
    

    Use reverse geocoding with component filtering to get the address component for one or more of the following types at the specified location:

    • administrativeArea
    • country
    • locality
    • postalCode
    • schoolDistrict

    The following example shows using the Geocoding service, adding component restrictions with reverse geocoding to retrieve all address components at the specified location for the locality type:

    https://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&result_type=locality&key=YOUR_API_KEY