android 基于邮政编码使用API获取位置详细信息[已关闭]

o2g1uqev  于 2023-06-27  发布在  Android
关注(0)|答案(4)|浏览(116)

**已关闭。**此问题正在寻求书籍、工具、软件库等的建议。它不符合Stack Overflow guidelines。目前不接受答复。

我们不允许问题寻求书籍,工具,软件库等的建议。您可以编辑问题,以便可以用事实和引用来回答。
3年前关闭。
Improve this question
在我的Android应用程序中,我想使用“国家”和“邮政编码”来获取“州名”和“城市”或“村庄名称”。
是否有任何API可用于获取这些信息?

jhkqcmku

jhkqcmku1#

对于印度,您可以使用以下API

  1. http://postalpincode.in/api/pincode/<your_pin_code>

回复:

  1. {
  2. "Message": "Number of Post office(s) found: 2",
  3. "Status": "Success",
  4. "PostOffice": [
  5. {
  6. "Name": "ISRO Anthariksha Bhavan",
  7. "Description": "",
  8. "BranchType": "Sub Post Office",
  9. "DeliveryStatus": "Non-Delivery",
  10. "Taluk": "Bangalore North",
  11. "Circle": "Bangalore North",
  12. "District": "Bangalore",
  13. "Division": "Bangalore East",
  14. "Region": "Bangalore HQ",
  15. "State": "Karnataka",
  16. "Country": "India"
  17. },
  18. {
  19. "Name": "R.M.V. Extension II Stage",
  20. "Description": "",
  21. "BranchType": "Sub Post Office",
  22. "DeliveryStatus": "Delivery",
  23. "Taluk": "Bangalore North",
  24. "Circle": "Bangalore North",
  25. "District": "Bangalore",
  26. "Division": "Bangalore East",
  27. "Region": "Bangalore HQ",
  28. "State": "Karnataka",
  29. "Country": "India"
  30. }
  31. ]
  32. }

对于国际邮政密码位置,请使用此

  1. https://api.worldpostallocations.com/pincode?postalcode=<your_pin_code_eg: 560094>&countrycode=<two_digit_country_code_eg:IN>

响应

  1. {
  2. "status": true,
  3. "result": [
  4. {
  5. "id": "305160",
  6. "country": "IN",
  7. "postalCode": "560094",
  8. "postalLocation": "ISRO Anthariksha Bhavan",
  9. "state": "Karnataka",
  10. "stateId": "19",
  11. "district": "Bengaluru",
  12. "districtId": "583",
  13. "province": "Bangalore North",
  14. "provinceId": "",
  15. "latitude": "13.1077",
  16. "longitude": "77.581"
  17. },
  18. {
  19. "id": "305159",
  20. "country": "IN",
  21. "postalCode": "560094",
  22. "postalLocation": "R.M.V. Extension II Stage",
  23. "state": "Karnataka",
  24. "stateId": "19",
  25. "district": "Bengaluru",
  26. "districtId": "583",
  27. "province": "Bangalore North",
  28. "provinceId": "",
  29. "latitude": "13.1077",
  30. "longitude": "77.581"
  31. }
  32. ]
  33. }
展开查看全部
wmtdaxz3

wmtdaxz32#

您可以使用Google Geocoding API,简单的HTTP请求和JSON响应。
示例:http://maps.googleapis.com/maps/api/geocode/json?address=94085&region=us

  1. {
  2. long_name: "California",
  3. short_name: "CA",
  4. types: [
  5. "administrative_area_level_1",
  6. "political"
  7. ]
  8. }

但请注意,免费层仅支持:

  • 2,500个请求/24小时。
  • 每秒5次请求。
wooyq4lh

wooyq4lh3#

如果使用Google地理编码器,则可以通过解析返回的json或xml并引用相应的字段来获取州和城市。例如:

  1. https://maps.googleapis.com/maps/api/geocode/json?address=94040

退货

  1. {
  2. "results" : [
  3. {
  4. "address_components" : [
  5. {
  6. "long_name" : "94040",
  7. "short_name" : "94040",
  8. "types" : [ "postal_code" ]
  9. },
  10. {
  11. "long_name" : "Mountain View",
  12. "short_name" : "Mountain View",
  13. "types" : [ "locality", "political" ]
  14. },
  15. {
  16. "long_name" : "Santa Clara County",
  17. "short_name" : "Santa Clara County",
  18. "types" : [ "administrative_area_level_2", "political" ]
  19. },
  20. {
  21. "long_name" : "California",
  22. "short_name" : "CA",
  23. "types" : [ "administrative_area_level_1", "political" ]
  24. },
  25. ...
展开查看全部
wa7juj8i

wa7juj8i4#

可能有帮助
https://www.whizapi.com/open-api/api-details?id=20
网址-> https://www.WhizAPI.com/api/v2/util/ui/in/indian-city-by-postal-code?AppKey=your-app-key&pin=110001
回复:

  1. {
  2. "ResponseCode": 0,
  3. "ResponseMessage": "OK",
  4. "ResponseDateTime": "11/10/2014 8:17:20 AM GMT",
  5. "Data": [
  6. {
  7. "Pincode": "110001",
  8. "Country": "INDIA",
  9. "City": "Central Delhi",
  10. "Address": "Baroda House"
  11. },
  12. {
  13. "Pincode": "110001",
  14. "Country": "INDIA",
  15. "City": "Central Delhi",
  16. "Address": "Bengali Market"
  17. },
  18. {
  19. "Pincode": "110001",
  20. "Country": "INDIA",
  21. "City": "Central Delhi",
  22. "Address": "Bhagat Singh Market"
  23. },
  24. {
  25. "Pincode": "110001",
  26. "Country": "INDIA",
  27. "City": "Central Delhi",
  28. "Address": "Connaught Place"
  29. },
  30. {
  31. "Pincode": "110001",
  32. "Country": "INDIA",
  33. "City": "Central Delhi",
  34. "Address": "Constitution House"
  35. },
  36. {
  37. "Pincode": "110001",
  38. "Country": "INDIA",
  39. "City": "Central Delhi",
  40. "Address": "Election Commission"
  41. },
  42. {
  43. "Pincode": "110001",
  44. "Country": "INDIA",
  45. "City": "Central Delhi",
  46. "Address": "Janpath"
  47. },
  48. {
  49. "Pincode": "110001",
  50. "Country": "INDIA",
  51. "City": "Central Delhi",
  52. "Address": "Krishi Bhawan"
  53. },
  54. {
  55. "Pincode": "110001",
  56. "Country": "INDIA",
  57. "City": "Central Delhi",
  58. "Address": "Lady Harding Medical College"
  59. },
  60. {
  61. "Pincode": "110001",
  62. "Country": "INDIA",
  63. "City": "New Delhi",
  64. "Address": "New Delhi G.P.O."
  65. },
  66. {
  67. "Pincode": "110001",
  68. "Country": "INDIA",
  69. "City": "Central Delhi",
  70. "Address": "North Avenue"
  71. },
  72. {
  73. "Pincode": "110001",
  74. "Country": "INDIA",
  75. "City": "Central Delhi",
  76. "Address": "Parliament House"
  77. },
  78. {
  79. "Pincode": "110001",
  80. "Country": "INDIA",
  81. "City": "Central Delhi",
  82. "Address": "Patiala House"
  83. },
  84. {
  85. "Pincode": "110001",
  86. "Country": "INDIA",
  87. "City": "Central Delhi",
  88. "Address": "Pragati Maidan Camp"
  89. },
  90. {
  91. "Pincode": "110001",
  92. "Country": "INDIA",
  93. "City": "Central Delhi",
  94. "Address": "Pragati Maidan"
  95. },
  96. {
  97. "Pincode": "110001",
  98. "Country": "INDIA",
  99. "City": "Central Delhi",
  100. "Address": "Rail Bhawan"
  101. },
  102. {
  103. "Pincode": "110001",
  104. "Country": "INDIA",
  105. "City": "Central Delhi",
  106. "Address": "Sansad Marg"
  107. },
  108. {
  109. "Pincode": "110001",
  110. "Country": "INDIA",
  111. "City": "Central Delhi",
  112. "Address": "Sansadiya Soudh"
  113. },
  114. {
  115. "Pincode": "110001",
  116. "Country": "INDIA",
  117. "City": "Central Delhi",
  118. "Address": "Secretariat North"
  119. },
  120. {
  121. "Pincode": "110001",
  122. "Country": "INDIA",
  123. "City": "Central Delhi",
  124. "Address": "Shastri Bhawan"
  125. },
  126. {
  127. "Pincode": "110001",
  128. "Country": "INDIA",
  129. "City": "Central Delhi",
  130. "Address": "Supreme Court"
  131. }
  132. ]
  133. }
展开查看全部

相关问题