Getting an intersection with Google Places/Geocoding API

EboMike picture EboMike · May 20, 2012 · Viewed 22.9k times · Source

I'm trying to find the two closest streets to a point with the Google Places API (basically to indicate the closest intersection). However, any result will only ever return one "route", if at all.

I figure I could do 5 queries in a + or X pattern, but that's hacky, unreliable, and of course will hit the query limit a lot sooner.

I am tempted to say that this is a deliberate move because the API is not meant to be used for something like navigation systems (which I'm not trying to do), but I still hope there's a TOS-compliant way to get the intersection.

Side note - it seems like specifying "types=route" never returns any results, which further nolsters my suspicion that Places is only really meant to be used for actual POIs, not for navigation, although the terms of service don't mention any explicit restrictions in that regard.

EDIT: As Chris pointed out, there's the Geocoding API that is specifically designed for geocoding, but I still don't see a way to get the closest cross street other than through multiple queries.

Answer

dmzza picture dmzza · Jun 6, 2013

GeoNames provides a Geocoding API for nearest intersection from latitude/longitude coordinates.

http://www.geonames.org/maps/us-reverse-geocoder.html#findNearestIntersection

The JSON response looks like this:

{"intersection":
 {"adminName2":"San Mateo",
  "street2":"Curtis St",
  "postalcode":"94025",
  "street1":"Roble Ave",
  "adminCode1":"CA",
  "distance":"0.08",
  "countryCode":"US",
  "lng":"-122.180842",
  "placename":"Menlo Park",
  "lat":"37.450649",
  "adminName1":"California"
 },
 "credits":"1.0"
}

street1 and street2 are the cross streets.