邮政编码
答
PH | |宿雾6000
是的,你可以...所有你需要做的是提取
http://maps.google.com/maps/geo?ll=纬度,经度
http://maps.google.com/maps/geo?ll=10.345561,123.896932
或者尝试尝试这种solutions.I可以给你出个主意。
你可以拥有一个城市吗?使用此json数据,如果您拥有此格式邮政编码的数据库(在maxmind.com)
CountryCode |城市|邮政编码
PH | |宿雾6000
现在查询数据库,是相对于,根据Google的回报COUNTRYCODE。
UPDATE
地址解析API V2已经推掉9月9日,2013年
这里的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;
}
您也可以从地址等信息,比如城市名称。
thanx ...让我试试 – Udaykiran 2011-05-02 10:10:21
从第一个......没有邮编来检索 – Udaykiran 2011-05-02 10:19:48
@Udaykiran你需要另一个有zipcode记录的数据库。这是database.http的例子:/ /ipinfodb.com/zipcode_database.php – kedomonzter 2011-05-02 10:25:44