我在java中使用谷歌地图API来检查某些地方是否正确,但我没有得到所有可能的响应:
GeocodingApiRequest req = GeocodingApi.newRequest(context).address("Sydney");
try {
GeocodingResult[] result = req.await();
System.out.println("number of results: "+result.length);
for(int i = 0;i < result.length;i++){
System.out.println(result[i].formattedAddress);
AddressComponent[] ac = result[i].addressComponents;
for(AddressComponent acSingle : ac){
System.out.println(acSingle.longName + " " + acSingle.shortName);
}
}
// Handle successful request.
} catch (Exception e) {
// Handle error
}
我得到以下输出:
number of results: 2
Sydney NSW, Australia
Sydney Sydney
New South Wales NSW
Australia AU
Sydney NSW, Australia
Sydney Sydney
New South Wales NSW
Australia AU
然而,如果您看看通过插入以下 url 请求可以获得什么,结果会更多:
Sidney https://maps.googleapis.com/maps/api/geocode/json?address=Sidney
在上面的链接中,您可以看到结果远多于 2,例如,俄亥俄州确实有 Sidney。
None
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)