【发布时间】:2013-02-03 11:11:10
【问题描述】:
我的应用中有一个地址字段,用户需要在其中输入所需的地址。我使用 google Geocoder 来获取地址的 GPS 坐标。但现在我想通过使用 Places Autocomplete 让用户更轻松。但是 Places Autocomplete 只返回地址、Id 和地址。
有没有办法使用 Places Autocomplete API 获取用户选择的地址的 GPS 坐标?用户从 Places Autocomplete 中选择他的地址后,我是否必须再次使用 Geocoder ?
或者我应该在用户选择他的地址后再次使用 Places API 来获取地址的 GPS 坐标吗?由于使用限制,我不想向 Places API 发送多个请求。 .这是 Places API 的预期响应。响应中没有 GPS 坐标。
"status": "OK",
"predictions": [ {
"description": "Paris, France",
"id" : "691b237b0322f28988f3ce03e321ff72a12167fd",
"reference": "CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "France",
"offset": 7
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}, {
"description": "Paris, TX, United States",
"id" : "518e47f3d7f39277eb3bc895cb84419c2b43b5ac",
"reference": "CjQjAAAAHnbxZZ...BDR3iIOFdMTxwo1jHg",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "TX",
"offset": 7
}, {
"value": "United States",
"offset": 11
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}, {
"description": "Paris, Ontario, Canada",
"id" : "e7ac9c89d4a590305242b0cb5bf43064027223c9",
"reference": "CjQhAAAAIv_YWYt...F8KZHY36TwMrbyu_g",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "Ontario",
"offset": 7
}, {
"value": "Canada",
"offset": 16
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}
【问题讨论】:
标签: android google-places-api google-geocoder google-geocoding-api