capabilities.work

Find the Nearest Open Place and Route to It

A 3-step recipe with Google Maps Platform. We can help you get access.

Recipe · 3 steps

Find the Nearest Open Place and Route to It

Go from a user coordinate to turn-by-turn directions to the nearest matching place.

  1. Find places of the requested types inside the circle, ranked by distance so the first result is the closest one rather than the most popular one.
  2. Read the nearest candidate in full to confirm it is operational and to pick up opening hours and a phone number before sending anyone to it.
  3. Route from the origin coordinate to the verified place. The destination is given as a place_id-prefixed value so the route lands on the exact place the search returned rather than a re-geocoded name.
What you'll need to have ready
  • latitude: Latitude of the search centre, normally the user's current position.
  • longitude: Longitude of the search centre, normally the user's current position.
  • apiKey: Google Maps Platform API key. The Directions API takes the key as the required `key` query parameter; the Places API takes it as the X-Goog-Api-Key header appli
  • radiusMeters: Radius in metres of the circle to restrict the nearby search to.
  • includedTypes: Place types to include in the nearby search (e.g. ["restaurant"]).
  • searchFieldMask: Comma-separated fields for the nearby search response, prefixed with "places." because results are nested under that key.
  • detailsFieldMask: Comma-separated fields for the Place Details response.
  • mode: Travel mode used to route to the place.
  • languageCode: BCP-47 language code for place results (e.g. "en").
  • regionCode: CLDR region code used to bias place results (e.g. "US").
  • units: Unit system used for the human-readable distance text.
For your developer

Arazzo workflow google-maps:nearby-search-to-directions, 3 operations: searchPlacesNearby → getPlaceDetails → getDirections. Specs on APIs.io.