Android:Google Place API queryAutoComplete在API 17-API 19上提供零结果
以下请求在web和android API 17+中运行良好: 搜索字符串:Android:Google Place API queryAutoComplete在API 17-API 19上提供零结果,android,google-places-api,nativescript,Android,Google Places Api,Nativescript,以下请求在web和android API 17+中运行良好: 搜索字符串:Bruņinieku ie 搜索url: 搜索结果: { "predictions" : [ { "description" : "Bruņinieku iela, Rīga, Latvija", "id" : "6904e5bf90ff4e34b179aba2e28643efc9007017", "matched_substrings" : [
Bruņinieku ie
搜索url:
搜索结果:
{
"predictions" : [
{
"description" : "Bruņinieku iela, Rīga, Latvija",
"id" : "6904e5bf90ff4e34b179aba2e28643efc9007017",
"matched_substrings" : [
{
"length" : 13,
"offset" : 0
}
],
...
现在,如果我在末尾添加另一个字母,那么请求在web和android API 21+中仍然可以正常工作,但在API 17-API 19中则不行:
搜索字符串:Bruņinieku iel
搜索url:
搜索结果(Web和API 21+):
搜索结果(API 17-API 19):
为什么?!毫无意义!起初,我认为可能是位置、半径或语言,所以删除了这些-仍然是相同的问题。这不应该发生,但它确实发生了。好极了,浪费了半天。事实证明,旧的API不会自动将未知符号(如
ņ
)转换为utf-8。您必须自己使用encodeURIComponent(搜索字符串)
来完成此操作,它会生成url:
{
"predictions" : [
{
"description" : "Bruņinieku iela, Rīga, Latvija",
"id" : "6904e5bf90ff4e34b179aba2e28643efc9007017",
"matched_substrings" : [
{
"length" : 15,
"offset" : 0
}
],
...
{
"predictions": [],
"status": "ZERO_RESULTS"
}