We would like to draw a route between two points by using Google Maps Directions API.
Request:
https://maps.googleapis.com/maps/api/directions/json?origin=39.76700140,30.50334660&destination=39.49402464,31.84024373
Response:
{
"geocoded_waypoints" : [ {}, {} ],
"routes" : [],
"status" : "ZERO_RESULTS"
}
It returns ZERO_RESULTS status. However, these two points can be geocoded and they are actual and valid points.
Does anyone know why the route can not be drawn although they can be geocoded?
Thanks in advance,
Mark
I found the reason for it. Google routes to points which are close to the roads at least 5 KMs.
That point is in rural area and not close to any roads at least 5 KMs. For that reason, it gives the error called ZERO_RESULTS.
Thanks,
Mark
Related
I'm currently working on an app with GoogleMaps API using their PlacesAutocomplete plugin to fill an input.
The problem which I encountered is that for the result types for Airports I get only establishment. I tried using establishment and geocode for parameters in the API call but with no luck. I either get only establishment or maximum transit_station in the results. The problem with transit_station is that all the train stations, airports, bus stations are marked the same.
I need a way to get the specific type for each of them, could someone help me please, maybe I'm doing something wrong.
You can see in the screenshot below the result from the API
According to the documentation, currently the types parameter of places autocomplete supports only following values:
geocode
address
establishment
(regions)
(cities)
https://developers.google.com/maps/documentation/javascript/places-autocomplete#add_autocomplete
LE: Found a workaround
In order to get the place type I used another API this time Place Details
I took the placeId from the Autocomplete request and fired a new request to the Place Details with the fields parameter set to types
https://maps.googleapis.com/maps/api/place/details/json?key=[YOUR_KEY]&placeid=ChIJRQFUJVRhRUcR-C4yT1Y4KWk&fields=type
And the result was
{
"html_attributions": [],
"result": {
"types": [
"airport",
"point_of_interest",
"establishment"
]
},
"status": "OK"
}
So by combining the two calls I was able to get even the type which in the Autocomplete was not available
The docs for the the Place Details can be found here
I have used the Google Place details API to get the place details which includes the lat/lng coordinates of a place.
When I launch Google maps using the Universal cross-platform Maps URL, it does not recognize the Place.
For example,
https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJbf8C1yFxdDkR3n12P4DkKt0&key=XXXXXXXX
returns the place details including the following location data:
{
.....
"geometry": {
"location": {
"lat": 27.1750151,
"lng": 78.0421552
},
"viewport": {
"northeast": {
"lat": 27.1770292,
"lng": 78.04537599999999
},
"southwest": {
"lat": 27.16897280000001,
"lng": 78.0388188
}
}
},
.....
"name": "Taj Mahal",
"place_id": "ChIJbf8C1yFxdDkR3n12P4DkKt0",
.....
}
But this data, when used to create a Maps URL with direction map action, does not give the correct place in the destination field.
Google Maps URL : https://www.google.com/maps/dir/?api=1&destination=27.1750151,78.0421552&destination_place_id=ChIJbf8C1yFxdDkR3n12P4DkKt0
The destination is not shown as a place. Only the lat/lng or address is used as below.
The correct/expected result is the following. Look at the destination.
Update
The issue seems to be with the PlaceID not matching the lat/lng coordinates in the Maps URL. There seems to be an inconsistency with lat/lng provided by the Place Details API.
Below URL works
https://www.google.com/maps/dir/?api=1&destination=27.1750151,78.0421552,15z&destination_place_id=ChIJbf8C1yFxdDkR3n12P4DkKt0
but 27.1750151,78.0421552,15z is not the coordinates from the Place details API. The lat/lng returned by PlaceDetails API is 27.1750151,78.0421552.
There is a difference of ,15z which I believe it is the zoom levels.
The destination parameter looks to be trumping the destination_place_id parameter completely when lat/lngs are supplied, causing a reverse geocode on the coordinates. In the following example URL, I'm using a Place ID of ChIJj61dQgK6j4AR4GeTYWZsKWw which corresponds to the Googleplex in Mountain View, CA as the destination_place_id along with the lat/lng for the Taj Mahal as the destination; notice the Googleplex query is ignored, and a reverse geocode is performed getting just the address in India:
https://www.google.com/maps/dir/?api=1&destination=27.1750151,78.0421552&destination_place_id=ChIJj61dQgK6j4AR4GeTYWZsKWw
So, the workaround is to not use a lat/lng as the destination parameter. I've tested with various strings (place names, addresses, gibberish) as that parameter, and the destination_place_id appears to supercede it, which is the desired behavior. When using just a .(period) as a universal value, the name of the place along with the address is supplied:
https://www.google.com/maps/dir/?api=1&destination=.&destination_place_id=ChIJj61dQgK6j4AR4GeTYWZsKWw
https://www.google.com/maps/dir/?api=1&destination=.&destination_place_id=ChIJbf8C1yFxdDkR3n12P4DkKt0
The documentation mentions for destination that The value can be either a place name, address, or comma-separated latitude/longitude coordinates.
If you enter coordinates, I suppose it just does a reverse geocode and displays the corresponding address. So you can input the place name and it will work.
https://www.google.com/maps/dir/?api=1&destination=Taj+Mahal&destination_place_id=ChIJbf8C1yFxdDkR3n12P4DkKt0
I use Google Maps Apis for geocoding to get full address for coordinates. It worked fine before revolution in Ukraine and the fact that Crimea currently is a part of Russian Federation. As result, nowadays I receive just this:
{
"results" : [],
"status" : "ZERO_RESULTS"
}
Do you know what is wrong?
Thanks.
FYI I got this answer from Google Support:
Since Crimea currently is a disputed territory (http://en.wikipedia.org/wiki/List_of_territorial_disputes), Geocoder results will currently not return results for reverse geocoding.
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.
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).