How to find postcode by latitude and longitude for UK

一个人想着一个人 提交于 2020-01-10 15:40:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!