Implemented the Places Web Service API - Place Autocomplete https://developers.google.com/places/web-service/autocomplete and works fine, but it doesn't return the Latitude and Longitude of theses places predicted!
That is the request!
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Amoeba&types=geocode&location=37.76999,-122.44696&radius=500®ions=locality&key=KEY
This is an intended behavior. According to the documentation the autocomplete response doesn't contain any location information:
https://developers.google.com/places/web-service/autocomplete#place_autocomplete_results
You have the place ID in the response, so you can execute either place details or geocoding request to get the location for the given place.
For example, in your request the first prediction has a place ID ChIJjxz0JSktaE0RJio-PNWLd60, so you can execute the following request to get coordinates:
https://maps.googleapis.com/maps/api/geocode/json?place_id=ChIJjxz0JSktaE0RJio-PNWLd60&key=YOUR_API_KEY
The response will contain required information
"geometry":{
"bounds":{
"northeast":{
"lat":50.0903542,"lng":-86.29135079999999
},
"southwest":{
"lat":50.0850891,"lng":-86.3070178
}
},
"location":{
"lat":50.0890102,"lng":-86.2987103
},
....
I can also see that the feature request was filed in Google issue tracker, but Google rejected it and marked as Infeasible:
https://issuetracker.google.com/issues/35827993
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
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
We noticed the google map geocoding api now returns different address types. For addresses used to be "street_address" in the "type" XML element, some could be "premise" instead. We are filtering the response based on the data value in the "type" XML elements in the response.
Besides "premise" and "street_address", is there any other value could be in the "type" XML element that would result in as a match to street level? What values have been added to it since Feb. 14th, 2017 in the Release version: 3.27? Where can I find the exact changes on the revisions related to google map geocoding api?
The change that you observe is not related to version 3.27 of Maps JavaScript API. Google has announced a new version of forward geocoder back in November 2016.
This version of geocoder can find more things than previous version could. For example POIs and businesses can be found as well.
Have a look at this example:
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3Daaa%26nfw%3D1
You can see the following types: "car_repair, establishment, insurance_agency, point_of_interest, travel_agency"
The changes also are described in the following documents:
https://developers.google.com/maps/documentation/geocoding/best-practices
https://developers.google.com/maps/documentation/geocoding/faq
Hope it helps!
Well for starters, here's a list of all the currently supported values for the type field: https://developers.google.com/maps/documentation/geocoding/intro#Types
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 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).