I want to use Google Places Autocomplete API to provide search-while-typing for an Android app.
the Autocomplete API returns IDs and References, requiring an iteration through the results to get the details (such as name and geometry) for each place, this is slow and results in a bad user experience. also, many API calls are done for each key press.
is there a better way to provide such searching capability with Google Places ?
Is there a reason you need to have the geometry for each possible autocomplete place after each keypress of the API? Showing this seems like generally it would not be a great user experience, and is not what the Autocomplete API was designed for.
In theory the name (description) should be enough for the user to decide which item they're interested in, and then after a user has actually selected something you can request additional details as needed.
On the other hand if you already have some information about the name of the place, you could use the Places API (not Autocomplete) to get additional details of matching nearby places:
https://developers.google.com/maps/documentation/places/#PlaceSearchResponses
Related
We are currently trying the Google places autocomplete api, but it seems as though Google places autocomplete api also returns invalid (non existent) addresses in the search result.
We want to receive only valid / actual addresses when the user types in the address autocomplete, is there a way to do it?
I searched the api docs but couldn't find anything much helpful.
There is a google places validation api but it only validates after given a single address, but we want to show only valid/actual addresses on search autocomplete and also don't want to call validation api for each of the search result items.
Went through official doc and also experimented several stackoverflow answers but those didn't match our requirements.
SO ref-1
This is Working as Intended as of now
I tried reproducing the Autocomplete request using this:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=332%20Kennedy%20drive,%20Torrington,%20CT&types=address&key=API_KEY
And the results returned has a long Place ID.
According to the Places API documentation:
"Place IDs uniquely identify a place in the Google Places database and on Google Maps."
The documentation also says that the API may return a different place ID in the response. These place ID types include:
Street addresses that do not exist in Google Maps as precise addresses, but are inferred from a range of addresses.
Segments of a long route, where the request also specifies a city or locality.
Intersections.
Places with an address component of type subpremise.
These IDs often take the form of a long string.
This explains why the API still returned a street address for the input =332 Kennedy drive, Torrington, CT using types=address. The use case of autocomplete is to help the users obtain the closest result even if they are requesting an ambiguous query. So the Autocomplete always tries to return the closest result to their input and types. In your case, it returned a street addresses that do not exist in Google Maps as precise addresses, but are inferred from a range of addresses.
There's a public bug on the issue tracker that is somehow related to this. On the comment #5, it says that:
Suggestions are sometimes created for addresses that may not exist, if there are chances that they do.
Retrieving details for such suggestions may result in the suggested address, if it actually exists or can be synthesized from existing data. Otherwise, the result may be a different address, one that actually exists.
Possible workaround
One thing you can do is to use the validation API.
But since you mentioned that you don't want to use it, I tried the Autocomplete request using this:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=332%20Kennedy%20drive,%20Torrington,%20CT&types=establishment&key=API_KEY
I just changed the types=address to types=establishment and it seems to return legit addresses. I'm not sure if this would fit on your use case, so you can just comment down if it does not.
And if it does not, I found a similar public bug on the issue tracker which says that similar issues like these are currently being worked on by the Google engineers internally. So what I would advise you to do wait for on update from this public bug.
There's no definite timeline on how long this will be fixed, but you can star it to be notified whenever there's an update.
Hope this helps!
== UPDATE ==
I tried playing around with the types and got to a point where I tried putting an array of types from this table. I tried this:
https://maps.googleapis.com/maps/api/place/autocomplete/json?input=332%20Kennedy%20drive,%20Torrington,%20CT&types=street_address|street_number|premise&key=API_KEY
and it did return some real addresses. I changed the types=address to types=street_address|street_number|premise. You could try it out yourself and play around with the types and see if it works for your use case.
for more information about types, here's a link to the documentation.
I'm reading the documentation of GM-APIs, I found the section relative to "Places", but I can't find anything to get the information about the per-hour number of customers for a certain place.
Do you know whenever you search a place on GMaps, there is an indication of the frequency of customers, in that way you can know if the place will be busy or empty.
Is there any way to retrieve that information through Google Maps API?
Currently, there is no available feature in Google Maps API that could get the exact number or the of people in an establishment to determine its busiest time of the day.
However, there is an existing Feature Request in Google Map Platform's Public issue tracker to expose the place's popular times which seems to be related to the feature you are looking for.
Here's the link to that feature request: https://issuetracker.google.com/35827350. You can star/favorite this feature request and feel free to leave a comment there regarding your use case for additional information as well.
I wanted to use Google Places API to get nearby places (music venues, pubs, theaters, etc.) in given city, then look for events in these places. And if you look at some places on google maps, you can see that there is a section 'Upcoming Events', so I'm sure the data is here. The problem is, Place Details endpoint does not provide with such information, although upon some research I found some information that told me otherwise, namely this, however I am aware that this information is pretty old at best. My question is - is this feature of API still available, or was it removed, or what?
Currently what I'm doing is first sending the request like this:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?key={api_key}&location={city}&radius={some_radius}
to get all the places available, then for each place_id in response:
https://maps.googleapis.com/maps/api/place/details/json?key={key}&placeid={place_id}
The fields in these responses are not including any info about events, even if the place have the section 'Upcoming Events' on google maps.
There is a feature request for Events API in the Google issue tracker:
https://issuetracker.google.com/issues/137032001
I would suggest staring the feature request to add your vote and subscribe to further notifications from Google. Hopefully one day they implement this API and expose events via APIs.
I am able to get restaurants list, timings, rating and displaying them in my Android application by using Google places API. This is API
https://maps.googleapis.com/maps/api/place/search/json?location=13.0104611,80.2086226&
radius=10000&types=cafe|restaurant&hasNextPage=true&nextPage()=true&sensor=false&key=MY_API_KEY
As per my client requirement, Users should be able to give rating to a specific restaurant from my application, this restaurant got from above Googel API.
Kindly tell me whether possible or not giving rating to a restaurant from above API . Thanks in advance.
According to the documentation, using the Google Places API Web Service, the following place requests are available:
Place Searches return a list of places based on a user's location or search string.
Place Details requests return more detailed information about a specific Place, including user reviews.
Place Add allow you to supplement the data in Google's Places database with data from your application.
Place Photos gives you access to the millions of Place related photos stored in Google's Place database.
Place Autocomplete can be used to automatically fill in the name and/or address of a place as you type.
Query Autocomplete can be used to provide a query prediction service for text-based geographic searches, by returning suggested queries as you type.
The only request that allows to put data is Place Add, but according to the documentation it adds a place that is available immediately in Nearby Searches initiated by your application and also enters a moderation queue to be considered for Google Maps.
So the answer is that for the time being it's not possible to add reviews to Places using the Google Places API Web Service.
I am looking to find out if Google Places Autocomplete should return results including my submitted places.
I have submitted a place to the Place Report endpoint, and got an
id and ref back.
I then want my users to be able to select that
place from an autocomplete box - along with all the other results.
I have added the browser API key to the Javascript src.
Is this how it's designed to work, 'cos it's not working like that at the moment - or am I being impatient / doing something wrong.
I have verified my Place has been added by calling up the details using the reference it returned when I added it...
Your Place Reports are supposed to be available immediately to your application, but they must pass through a Google moderation process before they become generally available to all users. From the User Place Reports section of the Google Places API Docs:
Place Report requests are used to add new Places, or delete existing
ones. New Places will be available immediately in Place Searches
initiated by your application, and will enter the moderation queue to
be considered for Google Maps. A newly-added Place will not be
available to other applications until it has been approved by the
moderation process.
It isn't clear from your question exactly how you performed your Place Report, so I assumed you had used the Google Places API.
Some additional info, based on your comment:
It makes sense that you can see the place you have added using the Places API, but that it doesn't appear when using Autocomplete. The Places API is designed to be very thorough (and of course, the new place was added by your application), while the Autocomplete is focused on being high-speed, low-latency, and is based almost entirely on how Google rates the prominence of nearby places. Assuming the newly added place has not yet had many clicks, ratings, etc. on maps.google.com, it makes sense that it will not yet rate very highly in prominence.
There is some very good information about the differences between the Autocomplete tool and the general Places API in the Autocomplete Demo & Places API Demo & Discussion Video, given by Paul Saxman, a Developer Advocate at Google and Marcelo Camelo, Google's Technical Lead for the Places API. There is a portion near the end where they discuss adding new places and I think it will help clarify the results you are seeing. Anyway, I hope it helps -