是的,你可以......所有你需要做的就是提取
http://maps.google.com/maps/geo?ll= 纬度,经度
http://maps.google.com/maps/geo?ll=10.345561,123.896932
Run Code Online (Sandbox Code Playgroud)
或尝试尝试这个解决方案.我可以给你一个想法.
你可以拥有一个城市吗?有了这个json数据,如果你有一个这种格式的zipcode数据库(在maxmind.com上)
CountryCode | 城市| 邮政编码
现在查询与googles返回的国家/地区代码相关的数据库.
UPDATE
Geocoding API v2已于2013年9月9日被拒绝.
这是API服务的新URL
http://maps.googleapis.com/maps/api/geocode/json?latlng=your_latitude,your_longitude
http://maps.googleapis.com/maps/api/geocode/json?latlng=10.32,123.90&sensor=true
基于地理编码器的实现:
private String getZipCodeFromLocation(Location location) {
Address addr = getAddressFromLocation(location);
return addr.getPostalCode() == null ? "" : addr.getPostalCode();
}
private Address getAddressFromLocation(Location location) {
Geocoder geocoder = new Geocoder(this);
Address address = new Address(Locale.getDefault());
try {
List<Address> addr = geocoder.getFromLocation(location.getLatitude(), location.getLongitude(), 1);
if (addr.size() > 0) {
address = addr.get(0);
}
} catch (IOException e) {
e.printStackTrace();
}
return address;
}
Run Code Online (Sandbox Code Playgroud)
您还可以从地址获取其他信息,例如城市名称。
| 归档时间: |
|
| 查看次数: |
7948 次 |
| 最近记录: |