Why do calls to the Google Maps Geocoder API return different results than what I see in my browser?
This one returns many items :
http://maps.google.fr/maps?q=McDonald,+paris
This one returns a ZERO_RESULT :
http://maps.googleapis.com/maps/api/geocode/xml?McDonald,+paris&sensor=false
FAQ: https://developers.google.com/maps/faq#geocoder_differences
The API geocoder finds postal addresses. The Maps geocoder uses lots of data, including business data, to find results.
There is the Places API which can find locations based on type/class, but it may not work for business names. Documentation
Related
I have signed up with the Google Maps API. I can geolocate locations using the following query
url = f"https://maps.googleapis.com/maps/api/geocode/json?address={city}&key={api_key}"
I need to do a search for towns by partial name.
For example 'MyTown' is a town , but there are also towns with names which include 'MyTown' in the title, such as MyTown-By-Sea, MyTown-SomethingElse and even NiceMyTown
The above query using the API returns just the city MyTown, not the others
Is there some option I have missed to get the Google Maps API to be less specific in the response returned ?
You can use Places Autocomplete API web service. This API will return places suggestions or predictions, based on your given input.
https://maps.googleapis.com/maps/api/place/autocomplete/json
?input=MyTown (based on your example)
&location=latitude,longitude
&key=YOUR_API_KEY
I'm using getQueryPredictions method to get autofill entries. The value of place_id in about 10% of returned places is a 40 characters long string that starts with "E". I'm trying to pass that place_id to google.maps.DistanceMatrixService().getDistanceMatrix method to get a distance between those places and other "normal" locations but Google does not return anything for such IDs.
You can easily get such "E" place_id if you use address "4498 INTERSTATE NORTH PARKWAY EAST SOUTHEAST" at this form from Map API Documentation It returns "EjM0NDk4IEludGVyc3RhdGUgTiBQa3d5IEUgU0UsIEF0bGFudGEsIEdBIDMwMzM5LCBVU0E" as place_id. Use that ID in any other Maps API mathods and Google won't recognize it as a valid place_id.
How can I use those weird IDs to look up distances? Or how can I transform them into normal place_ids?
I created an API key and used the referred place_id, which returned a valid response.
https://maps.googleapis.com/maps/api/place/details/json?placeid=EjM0NDk4IEludGVyc3RhdGUgTiBQa3d5IEUgU0UsIEF0bGFudGEsIEdBIDMwMzM5LCBVU0E&key=[API_KEY]
Its not specified, but not all Google Maps API can be used with place_id.
You can use the same place ID across the Google Places API and a number of Google Maps APIs. For example, you can use the same place ID to reference a place in the Places API, the Google Maps JavaScript API, the Google Maps Geocoding API, the Google Maps Embed API and the Google Maps Roads API.
For your getDistanceMatrix to work, your destinations[] should either be string, LatLng, or Place objects. You'll have to use the place_id to get the place details (which has the LatLng that you can use for getDistanceMatrix).
I'm using google maps to geocode. But I have 280k address to geocode, I would like to know a better option for this.
Thank you.
I looked for Bing and Yahoo! tutorial to make the geocoder, but nothing was found, only plotting tutorials.
Bing Maps has a couple of different options for geocoding data. There is a lot of information out there on this as well.
The batch geocoder in Bing Maps allows licensed customers to geocode up to 25 files of 200,000 addresses a day. Unlicensed customers are limited to 50 addresses per file. Documentation:
http://msdn.microsoft.com/en-us/library/gg585136.aspx
http://msdn.microsoft.com/en-us/library/ff701733.aspx
Bing Maps also has an on-demand REST geocoding service which can geocode one address at a time. Here is some documentation:
http://msdn.microsoft.com/en-us/library/ff701715.aspx
http://msdn.microsoft.com/en-us/library/jj819168.aspx
http://msdn.microsoft.com/en-us/library/jj870778.aspx
http://blogs.bing.com/maps/2013/02/14/bing-maps-rest-service-tips-tricks/
All this said, it should be noted that there are restrictions around geocodes with most mapping platforms. Generally they can not be used with competing mapping platforms. i.e. Data geocoded by Bing Maps cannot not be used in a Google Maps application.
I was typing "macys" as the search item in here (google maps website) which gives me around 30 to 40 results marked on the map.
Where as when I use their API with query term "macys" then it returns only 2 to 3 results. I am using the following api:
http://maps.googleapis.com/maps/api/geocode/json?address=macys&sensor=false
I am possibly using the wrong API because it says as 'address' in the query parameter. Which API should I be using for getting all macys locations in the US / World?
I want it to return all the lat and lng objects as if its done in their own website (google maps website). If they have not exposed the API then is there a way around?
You should use the Places API:
https://developers.google.com/places/documentation/
Geocoding is not designed to return POIs, it might return some, but you should not depend on it.
Does google maps api support "suggestions" ?
In other terms, can I receive from google maps the suggestions given a submitted query ?
thanks
You can use the Geocoding API, which according to the documentation will return multiple results:
Generally, only one entry in the
"results" array is returned for
address lookups, though the geocoder
may return several results when
address queries are ambiguous.
You should try using the maps api autocomplete which will return suggestions for locations
Google Maps API Places Auto Complete