kami998
kami998

Reputation: 91

How to find postcode by latitude and longitude for UK

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.

Upvotes: 4

Views: 3469

Answers (2)

user370305
user370305

Reputation: 109237

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" /> 

Upvotes: 7

Widor
Widor

Reputation: 13265

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).

Upvotes: 0

Related Questions