Names of streets adjacent to a building in Google Places API

445 Views Asked by At

I'm retrieving geocoordinates for particular locations (e.g. a trainstation) using the Google Maps Places API.

I would now like to get the names of streets adjacent to the building (e.g. on two or three sides of the building).

Is there a straightforward way to do this?

1

There are 1 best solutions below

0
Angelica On BEST ANSWER

You may use Roads API -- Nearest Roads which returns the closest road segment for each given point.

See sample request: https://roads.googleapis.com/v1/nearestRoads?points=40.675138,-73.949893|40.674904,-73.949919&key=YOUR_API_KEY

Which returns the place IDs for roads St Marks Ave and Nostrand Ave in Brooklyn, NY:

{
    snappedPoints: [
        {
            location: {
                latitude: 40.675207313469635,
                longitude: -73.94988632960607
            },
            originalIndex: 0,
            placeId: "ChIJ-fmHuZxbwokR9DK_otCAI-8"
        },
        {
            location: {
                latitude: 40.67490969962758,
                longitude: -73.95002762271577
            },
            originalIndex: 1,
            placeId: "ChIJeTc98pxbwokR7npFqW-oC58"
        }
    ]
}

Place IDs can be used with other Google APIs, including the Places API and the Maps JavaScript API. For example, if you need to get road names for the snapped points returned by the Roads API, you can pass the placeId to the Places API or the Geocoding API.

Hope this helps!