Closed diarmaidlindsay closed 4 years ago
Hi, @diarmaidlindsay
Fair enough! I just updated to 0.6.0 with requested function including other parameters you can use with autocomplete()
Although I ran a few tests, please let me know if you find any issue with the new version.
Works great! Thanks very much. While testing it out I noticed although we could now filter by country, it would be great if we could narrow it down further, since the user might want only results from a specific city (such as their current location).
According to the specs for the autocomplete webservice HERE, in addition to the types, components, radius, offset, language you kindly exposed, there is also 1 more additional "region" parameter.
Would you mind also exposing that too please?
No problem ;)
Regarding the 'region' parameter, I could not find the information in the google document about how exactly it works, which is why I did not include in the option. I thought the location/radius will restrict the result with strictbounds parameter.
Can you please tell me how the 'region' parameter works, so that I can guide users for the usage in ReadMe document? (or some example of usage?) Is it a JSON string including locality or postcodes?
I do really want to add what you asked for because it would definitely be useful to the users who need it. But please understand that I could not add a function before I understand it completely. I will read more about it from Google document in the meanwhile, but it would be awesome if you could guide me as you know much better about how it works.
I will then update as soon as possible. Appreciate for your understanding.
I will read more about it from Google document in the meanwhile, but it would be awesome if you could guide me as you know much better about how it works.
Actually it seems you were correct. The region parameter seems to affect what is returned from the autocomplete result rather than filtering the request. According to THIS Stackoverflow article, there is still unfortunately no way to filter by a given city.
the location/radius will restrict the result with strictbounds parameter.
Again you are correct, and I was able to achieve rough city-based filtering with this approach.
I will close this issue since you have exposed basically all of the functionality which is needed in the Autocomplete. Thank you!
@diarmaidlindsay, My assumption was wrong actually.
I deep-dived into google documents and 'google maps webservices' package, and found that region parameter actually works as you expected, BUT not local region(city) based. It is country-based.
The 'region' parameter is used in the 'Place search' API as you might already know, and it seems somehow share the code with 'Place autocomplete' API internally.
I tested it out and as it works correctly, I decide to update the package. Please refer to below information about using 'region' field and make sure to update to version 0.6.1
Just to make sure that (as it specified) the region you specified will be omitted from the result of 'formatted_address'.
region — The region code, specified as a ccTLD (country code top-level domain) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some exceptions. This parameter will only influence, not fully restrict, search results. If more relevant results exist outside of the specified region, they may be included. When this parameter is used, the country name is omitted from the resulting formatted_address for results in the specified region.
I truly appreciate your contribution to the project. (Also for the coffee ;))
Google's API allows for specifying a list of
Component
inside the _google_mapswebservice plugin. Using this it is possible to narrow down the Autocomplete results to things like Country, Postal Code, Locality... My request is to please allow for the use of aList<Component>
when initialising yourPlacePicker
, or a similar solution. You can pass those directly into your call toPlaceProvider.places.autocomplete()
in_performAutoCompleteSearch
in autocomplete_search.dart.This would be a big help to me and my users, as currently most of the autocomplete results are for places outside of their country.