Reputation: 159
I am trying to use Google Maps API to give me an autocomplete to find nearby bars by typing in the bar you are looking for. This doesn't seem to fall into the user stories of the API. I am having problems figuring out what combination of tricks I need to use to accomplish this.
The autocomplete function does not have granular enough place types (establishment, geocode) to filter only for bars so my predictions are full of gas stations, law offices and graveyards.
The nearbysearch is granular enough to filter type=bar but cannot be used as an autocomplete because the name and keyword parameters are exact matches. So when I search for "craw" I get ZERO_RESULTS not "Crawdaddy's".
Next I thought I would Get the predictions, do a radarsearch of the same location applying the type=bar filter and I would only take predictions that were in the radar results based on the reference number. NO GO either the radar search is using a different reference number than autocomplete or it is not returning the nearest type=bay to my location.
So ultimately, I am asking am I on a fools errand here or is there someway to implement an autocomplete that is filtered by business type?
Thanks, Tal
Upvotes: 0
Views: 1431
Reputation: 19672
I'm sorry to be the bearer of bad news. I'll go through your three possible ideas:
The autocomplete will match for keywords. Lawyers usually call themselves barristers, so you've got the wildcard screwing you up on that one. However, there is an optional types parameters that will allow you to filter by type in there, if that is any help.
I am actually having the opposite results on this one. Using the following parameters:
query=etoi types=bar location=50,2 sensor=true radius=20000
Yields as first result:
{ "geometry" : { "location" : { "lat" : 50.1089160, "lng" : 1.831840 } }, "icon" : "http://maps.gstatic.com/mapfiles/place_api/icons/bar-71.png", "id" : "3ec8233a732b4ee70dbb03034e2e20f84517763d", "name" : "L'Etoile du Jour", "rating" : 4.30, "reference" : "CnRuAAAAgOI6rLfSjaWyY_MRdK8zybHJOmAoqBLEtAgIxaZN5_UAS7WbWSYBukIro9ZCuiXSa9_HCOeHUmKPKkS6j9lxrET8cRX089azCKfvbR-lMFmzUb3Sd2VoWr02yPGJhXDBT7TjMpPPiuTWsZCY0Mcy9xIQHiE-o5v_EURALkxNElUPnRoUXcuht7Ov6k64DT1eA8-t9NR6-O8", "types" : [ "bar", "restaurant", "food", "establishment" ], "vicinity" : "2 Chaussée Marcadé, Abbeville" },
So I am guessing that there is more at play, but you'll have to ask Google on this one or provide your exact search params (excluding key) for me to look into.
Upvotes: 1