Google 地方 API - 我可以分离出输出吗?
Google places API - Can I separate out the output?
到达终点:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Hoboken%20NJ&fields=formatted_address,name&inputtype=textquery&key=xxxxxxxxxxxxxxxxxxx
得到结果:
{
"candidates" : [
{
"formatted_address" : "New Jersey, USA",
"name" : "Hoboken"
}
],
"debug_log" : {
"line" : []
},
"status" : "OK"
}
让我苦恼的是我找不到区分地区和国家的方法 - 是的,我知道我可以自己解析结果。但是有没有一个选项我可以选择 Google Places API 来将响应从返回的 JSON 中的 city/state(或地区)/国家分开?
类似于:
{
"candidates" : [
{
"state" : "New Jersey",
"country" : "USA",
"name" : "Hoboken"
}
],
"debug_log" : {
"line" : []
},
"status" : "OK"
}
据我所知,这是不可能的,你必须解析它。 Places API 旨在首先搜索商家和 POI。
Google 确实有,但是 geocoding API 似乎单独给出了邮政编码、国家、州、地址。
还有 some 个免费替代品
到达终点:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Hoboken%20NJ&fields=formatted_address,name&inputtype=textquery&key=xxxxxxxxxxxxxxxxxxx
得到结果:
{
"candidates" : [
{
"formatted_address" : "New Jersey, USA",
"name" : "Hoboken"
}
],
"debug_log" : {
"line" : []
},
"status" : "OK"
}
让我苦恼的是我找不到区分地区和国家的方法 - 是的,我知道我可以自己解析结果。但是有没有一个选项我可以选择 Google Places API 来将响应从返回的 JSON 中的 city/state(或地区)/国家分开?
类似于:
{
"candidates" : [
{
"state" : "New Jersey",
"country" : "USA",
"name" : "Hoboken"
}
],
"debug_log" : {
"line" : []
},
"status" : "OK"
}
据我所知,这是不可能的,你必须解析它。 Places API 旨在首先搜索商家和 POI。
Google 确实有,但是 geocoding API 似乎单独给出了邮政编码、国家、州、地址。
还有 some 个免费替代品