问题
I am working on a android app in which i came across a situation in which i need to get the current user postcode, so i am getting the current latitude and longitude but is there any way to find the current postcode by providing latitude and longitude.
If any web service or database to provide this information is available then please let me know about it.
回答1:
If you are talking about PostalCode then, use this..
Geocoder geoCoder = new Geocoder(getApplicationContext(), Locale.getDefault());
List<Address> address = null;
if (geoCoder != null){
try {
address= geoCoder.getFromLocation(latPoint, lngPoint, 1);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (address.size()> 0){
String postCode = address.get(0).getPostalCode();
}
With these two permission on Manifest file..
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
回答2:
At present the only official source of this data is the Royal Mail's Postcode Address File (PAF), which requires a licence (at some cost).
来源:https://stackoverflow.com/questions/10279230/how-to-find-postcode-by-latitude-and-longitude-for-uk