Closed martin-braun closed 1 year ago
After looking more in details, I understood that using places.searchNearbyWithRankby
would not work as it doesn't provide the same kind of output as the actually used places.autocomplete
(respectively PlacesSearchResponse
and PlacesAutocompleteResponse
).
I also looked in the autocomplete documentation and found that there should be a way to make these with autocomplete as well, it mentions rankby=distance
here but this one is weirdly not mentionned in the parameters. But the parameters' category locationbias seems to be offering many ways to control which results come first and are favored. These sadly don't seem to be readily available google_maps_service, they may have been added to places later on.
Not wanting to update all that by myself, I tried to "play" around with the values that are already available and sound alike.
I did some more digging and found that setting autocompleteRadius
is a good temporary workaround not depending on the locale of the device. But it sadly doesn't order by proximity (For example autocompleteRadius:5000
will first give me results less than 5000m away, but the top one might not be the closest one).
And then I tried lowering the value to see what happens if the closest result is much further than my minimum radius.
It seems that setting autocompleteRadius:5
orders the results by order of proximity and I guess that if many results are present less than 5 meters away from the user, they can be ordered in any way without it impacting the user.
I think that the most important at the moment is to add in the documentation that autocompleteRadius
can be used to order the results by proximity. If you still want to add the locationbias
(as I am not sure if rankby=distance
is really possible) I could maybe guide you in the process for the google_maps_service side (I think I understood where the changes are needed).
@Dereumaux-Adrien Thanks for your analysis and great work so far, it helps to find the shortcut, as I'm currently rather maintaining than enhancing this library due to time constraints. autocompleteRadius
seems to be sufficient for the problem and I think the caveat in regards of the lack of proximity ordering for the specified radius is not even a problem and rather a feature.
If I have a radius of 5km that I'm accepting to travel for the best destination, I want the best/largest/most known location of my search within that radius, not the closest one. If I want to travel the least possible, autocompleteRadius:1
should be the way to go. autocompleteRadius:1
should then still give results ordered by range outside of such radius, if I understand you correctly.
If you feel confident, I would highly appreciate if you could update the README to document the property properly. Otherwise I will update it later myself.
Thanks again, brother.
_Originally posted by @Dereumaux-Adrien in https://github.com/martin-braun/google_maps_place_picker_mb/issues/32#issuecomment-1384640201_
_Originally posted by @martin-braun in https://github.com/martin-braun/google_maps_place_picker_mb/issues/32#issuecomment-1385560033_