1
votes

I've been working on a project that requires me to get the address of a location from the name of the venue.

I'm doing this through Google's Geocoding API. However I see that sometimes, the wrong address and coordinates are returned. Searching for the location on Google returns the correct address.

eg: 'Queen Elizabeth Theatre - Toronto'

http://maps.google.com/maps/api/geocode/xml?address=Queen%20Elizabeth%20Theatre%20Toronto

What I would like is, '190 Princes' Blvd, Toronto, ON M6K 3C3', as per Google search.

This thread, Google Geocoding returning totally different result from Google Map, indicated that to get the right address I'd have to use Places API.

But for Places API to work I need to submit additional parameters other than just the name of the venue. Like approx. coordinates, and range of search, which I don't have (unless I get it with Geocoding API and then guess a search radius).

So what is the best way to get it?

Of course, I can scrape the page after searching for the location, but isn't scraping against Google's TOS?

1
I get a result for 190 Princes' Blvd, Toronto, ON M6K 3C3 from the Google Maps Javascript API Geocoder and from the Geocoding API Can you provide the code you are using that is failing to return a "good" result? - geocodezip
I put the link to the Geocoding XML link in my post. In your links you are searching for the address '190 Princes' Blvd, Toronto, ON M6K 3C3' instead of the venue, 'Queen Elizabeth Theatre - Toronto'. I am expecting this link, maps.google.com/maps/api/geocode/…, to return '190 Princes' Blvd, Toronto, ON M6K 3C3'. For the Javascript API, the correct result is returned, but I don't think I can use that API since the data is being collected on the backend through PHP. Correct me if I'm wrong about the last statement please. - fractal5
Queen Elizabeth Theatre - Toronto is definitely not an address. The geocoder will not work for that. You either need to use the address (which you have "190 Princes' Blvd, Toronto, ON M6K 3C3"), or use the places API - geocodezip
I see. I was under the impression that Geocoding API would allow me to get the address of a place by inputting the venue name. But I see it doesn't always work. - fractal5
Not in general. Some well-known "places" may be in the database (like the Eiffel Tower and the Statue of Liberty), but in general that is what the places API is for. - geocodezip

1 Answers

2
votes

The Geocoding API is intended to be used to translate addresses to geographic coordinates.

To find the location or address of a business or establishment (e.g. a theater), you should use the Google Places API. The Places API Text Search endpoint will allow you to query for the details of an establishment using only the name of that establishment. For example:

https://maps.googleapis.com/maps/api/place/textsearch/xml?query=Queen%20Elizabeth%20Theatre%20Toronto&key={yourkeyhere}

To use the API you will need an API key. See the Authentication section of this page for details on obtaining an API Key from the Google Developers console.