I am trying to use the Google Maps API to get the latitude and longitude of a few locations. For some reason, whenever I send a place name with an apostrophe, it does not return any results.
For instance, if I send the following requests for searching Berri's Pizza Cafe I get the results mentioned below
http://maps.googleapis.com/maps/api/geocode/json?address=berri%27s+pizza+cafe&sensor=false
{"results" : [], "status" : "ZERO_RESULTS"}
And this
http://maps.google.com/maps/geo?q=Berri%27s%20Pizza%20Cafe&output=json
{
"name": "Berri's Pizza Cafe",
"Status": {
"code": 602,
"request": "geocode"
}
}
I assume this is a problem with Google Maps API (found a forum post saying this was an issue in the javascript API but was supposedly fixed there, probably not in this)
Does anyone have a workaround for this situation?
Thanks.
The issue is that you are attempting to geocode a business name; the geocoder works with postal addresses. Omitting the apostrophe doesn't get any results either (thus proving it's not the apostrophe which is the problem).
Note that the Maps geocoder is far more sophisticated and uses a variety of data sources to locate targets, including address geolocation and business name lookup.
You may be able to find the data you're looking for using the Places API (but you will need to specify the city which you are currently omitting).
Related
I'm using Google Maps Place API restricted to cities research, hence I get city, state and country plus conditions and forecast10day Wunderground API.
It seems sometimes I've issues building the Wunderground API endpoint.
When I have a city available in just one country, I've this endpoint:
http://api.wunderground.com/api/{KEY}/conditions/q/IT/Milan.json
and it works like a charm.
When I know the city I'm searching for is available in many countries, I add the "state" value to the endpoint, like this:
http://api.wunderground.com/api/{KEY}/conditions/q/US/PA/Lancaster.json
The issue comes when I search for New Delhi in India (and at this point I'm afraid also for other cities):
http:// api.wunderground.com/api/{KEY}/conditions/q/IN/DL/NewDelhi.json
In this case the response is this:
"error": {
"type": "querynotfound",
"description": "No cities match your search query"
}
But If I call conditions/ for New Delhi in India via "zmw" parameter
http://api.wunderground.com/api/{KEY}/conditions/q/zmw:00000.1.42182.json
I see this in "display_location" object:
"city":"New Delhi / Safdarjung",
"state":"DL",
"state_name":"India",
"country":"IN"
So, it seems that formally my endpoint is right.
What am I going wrong in?
PS: I'm using Google Maps Place API 'cause it's also UI ready. :)
I've contacted the Wunderground tech support.
Well - as they told me - their API is a little bit inconsistent, so for places outside of US, the best solution is to make an API call via lat/lng values, so to ensure always the same response structure.
For me it has been possible 'cause via Google Maps Places I save also lat/lng values for the city I'm searching for.
So, you can build this endpoint:
https://api.wunderground.com/api/{KEY}/conditions/q/{lat},{lng}.json
and it works like a charm!
I'm a french developer and I have question about GMAP Geocoding API.
I'm on a new website work, which use this API.
The Geocoding API is used to get geocoded boundaries of french cities when user enter a french postal code.
So I request the API by this URL : https://maps.googleapis.com/maps/api/geocode/json?address=MY_ZIP_CODE&components=country:fr&key=my_key
In France, sometimes there is multiple cities for one postal code.
The default city is written in the JSON in address_components, "types" : [ "locality", "political" ] and all the cities are writtent in "postcode_localities".
(have an example in screenshot).
Last week, everything was working good.
But today, I've got a big probleme... When I use postal code (69510, 69310, 69600, etc....) multiple cities or alone city aren't no longer displayed.... But it works good for "69530".
It's embarassing for me because the website I'm bulding use the postal code to do a geolocated search with km radius...
Do you know if this API was update ?
I've search on Google.... But I've never find an answer.
Thanks in advance for your help !!
Have a nice day
My screenshot that show the API JSON answer
I was experiencing this problem as well yesterday. #xomena was right.
They updated their API at the end of November/beginning of December, and started more strictly encouraging best practices – using the Geocoding API for complete postal code strings (for example, “48 Pirrama Rd, Pyrmont, NSW, Australia”), and the Places API for more ambiguous addresses and semantic locations, including businesses and points of interest.
Specifically their blog post said:
Future Changes to Geocoding API
We plan to roll out an update to the Geocoding API at the end of November 2016 that will increase the difference between Geocoding and Places performance for ambiguous and unambiguous queries. This change will improve the quality of Geocoding results for unambiguous queries, but will be more likely to return ZERO_RESULTS for ambiguous or incomplete queries where the Geocoding API was unable to find a high quality result.
If you are already using the above best practices, you should see an improvement in your Geocoding API results. If you are currently using the Geocoding API for incomplete or ambiguous queries, or for queries that may contain non-address information such as business names or apartment numbers, we recommend that you switch to the Places API instead, as it is likely to give better quality results for your use case.
Try using the Place Search API instead! https://developers.google.com/places/web-service/search
Please file a bug in the Google Maps API issue tracker.
This is not related to the new geocoder, you'll see that adding new_forward_geocoder=false to your requests makes no difference.
The postcode_localities field is never exposed in Places API.
I am experiencing the same problem as described by #Jean-Baptiste.
I opened an issue : http://code.google.com/p/gmaps-api-issues/issues/detail?id=11087
Thanks for your answers.
That's true, the Places API can't give an autocompletion and the Autocomplete API doesn't give me satisfaction.
I've change my JS API parser and I get geocoding datas even if the postcode localities exists. If the zip code exists, so the geocoding datas exist.
That's a solution.... The visitor knows the zip code of the city where he lives. And for a major part of cities, the zip code is ok.
I saw that www.booking.com has the same problem...
Screenshot of the same problem on booking.com
That's solved for me ;-)
Thanks !!
For the Google Geocoding API (any version), is there any way to know if the response location (coordinate - latitude and longitude) is refereed to a 'house', a 'building' or none of them?
The idea here is to 'categorize' the location.
Given a list of human readable addresses (street name, number, zip, etc) I need to categorize each one of them as 'House', 'Building' or 'None'.
Request example:
https://maps.googleapis.com/maps/api/geocode/json?address=Dieciocho%2045%2C%20Santiago%2C%20Region%20Metropolitana&key={{key}}&components=country:CL
With the example the "location_type" is "ROOFTOP" (perfect accuracy) but even thou I don't see any address_component that can give me the information I need. Am I missing something?
I have read the api documentation (https://developers.google.com/maps/documentation/geocoding/intro#GeocodingResponses) but didn't find anything helpful for the case.
Does anyone know how to achieve this result?
Thank you in advance
There is a way in the Geocoding API (and Places API) to tell whether a result is known (to Google Maps) to be a building of some sort or not.
In your example, "types" : [ "street_address" ] indicates the address is not tied to a specific building, in the API. There may actually be a building at that location in real life, it's just that the API does not know about it. So this is kinda telling you "don't know".
In the following example, "types" : [ "premise" ] the result indicates this is some kind of building... but as you can see, it's actually a cathedral:
https://maps.googleapis.com/maps/api/geocode/json?latlng=-29.903018,-71.251052
For more fine grain distinctions, Places API Text Search lets you search for pretty much everything Google Maps does, and shows more types. These don't seem like they'll be enough to tell residential houses from other buildings though, may want to file a feature request for that.
For such a purpose, use Google Places API.
From JS v3 API, snippet is like this:
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
location: new google.maps.LatLng(...),
radius: 10,
type: ['store']
}, callback);
https://developers.google.com/maps/documentation/javascript/examples/place-search
I've been trying to find specific place in Google Places API with no success. When I type "La Cucina Trattoria" in Google Maps I get three results. However, when I run this query:
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=API_KEY&input=la%20cucina%20trattoria
I only get two results. So I've tested more queries with similar effectiveness:
input=la%20cucina%20trattoria%20gmbh - no results
https://maps.googleapis.com/maps/api/place/search/json?key=API_KEY&location=48.139649,11.602685&rankby=distance&keyword=cucina - place missing in results (I've put its exact location as a parameter)
location=48.139649,11.602685&rankby=distance&keyword=Neherstraße%209 - place missing in results (however, it is returning results from the same street)
My client named two random places he knows and none of them could be found in Google Places API. Is it possible that Google Places API and Google Maps operate on two different databases? Or can these places be hidden in the public API?
I've come across similar issues, but usually changing the query gave better results. Aside from reporting it, you can manually add a place:
POST https://maps.googleapis.com/maps/api/place/add/json?key=AddYourOwnKeyHere HTTP/1.1
Host: maps.googleapis.com
{
"location": {
"lat": -33.8669710,
"lng": 151.1958750
},
"accuracy": 50,
"name": "Google Shoes!",
"phone_number": "(02) 9374 4000",
"address": "48 Pirrama Road, Pyrmont, NSW 2009, Australia",
"types": ["shoe_store"],
"website": "http://www.google.com.au/",
"language": "en-AU"
}
This should allow your application to immediately see the place and potentially have it added into Google Maps.
I was unable to find La Cucina Trattoria in Places, and I tried a number of different tactics, including a Text Search (https://maps.googleapis.com/maps/api/place/textsearch/xml?query=italian restaurant on Neherstraße in munich&key=MYKEY). I'd report it to the Place API Issues tracker here: https://code.google.com/p/gmaps-api-issues/issues/list?can=2&q=apitype:PlacesAPI%20type:Defect&sort=-stars&colspec=ID%20Type%20Status%20Introduced%20Fixed%20Summary%20Internal%20Stars
Check through the extensive list of existing bugs to see if you can add your name to an existing one and speed its resolution. Here are some similar confirmed bugs:
Some queries return no results when there should be many
Bug: Sparse search results in germany
Bug: Place details request returns wrong result
I am searching for the way to identify lat/lng coordinates of street intersections of, for example, city blocks in specified area. Previously, I tried to utilize the data from OpenStreetMap to do this, but it is not working well. (Please refer to my previous question: "How can I exhaustively collect latlng coordinates of street intersections from OpenStreetMap (or from any other data)?")
I was searching for the alternative method, and I found that Google Places API seems to offer the data I want. In the following page (link), Google says that it supports the Place Type "intersection". I tried the following url to access their API (with replacing MY_API_KEY with my Google API key),
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=38.8962391,-77.0280818&radius=1000&types=intersection&sensor=false&key=MY_API_KEY
but no luck, it returned
{
"debug_info" : [],
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
I was wondering why this is not working. Is it because I am in the area that the service is not supported (the area I specified above is in Washington D.C.), or am I making some mistake in the query? Is there any walk around to this or do you know better way to find the street intersection coordinates?
Thanks.