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

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

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

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

jhkqcmku

jhkqcmku1#

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

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

回复:

{
  "Message": "Number of Post office(s) found: 2",
  "Status": "Success",
  "PostOffice": [
    {
      "Name": "ISRO Anthariksha Bhavan",
      "Description": "",
      "BranchType": "Sub Post Office",
      "DeliveryStatus": "Non-Delivery",
      "Taluk": "Bangalore North",
      "Circle": "Bangalore North",
      "District": "Bangalore",
      "Division": "Bangalore East",
      "Region": "Bangalore HQ",
      "State": "Karnataka",
      "Country": "India"
    },
    {
      "Name": "R.M.V. Extension II Stage",
      "Description": "",
      "BranchType": "Sub Post Office",
      "DeliveryStatus": "Delivery",
      "Taluk": "Bangalore North",
      "Circle": "Bangalore North",
      "District": "Bangalore",
      "Division": "Bangalore East",
      "Region": "Bangalore HQ",
      "State": "Karnataka",
      "Country": "India"
    }
  ]
}

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

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

响应

{
  "status": true,
  "result": [
    {
      "id": "305160",
      "country": "IN",
      "postalCode": "560094",
      "postalLocation": "ISRO Anthariksha Bhavan",
      "state": "Karnataka",
      "stateId": "19",
      "district": "Bengaluru",
      "districtId": "583",
      "province": "Bangalore North",
      "provinceId": "",
      "latitude": "13.1077",
      "longitude": "77.581"
    },
    {
      "id": "305159",
      "country": "IN",
      "postalCode": "560094",
      "postalLocation": "R.M.V. Extension II Stage",
      "state": "Karnataka",
      "stateId": "19",
      "district": "Bengaluru",
      "districtId": "583",
      "province": "Bangalore North",
      "provinceId": "",
      "latitude": "13.1077",
      "longitude": "77.581"
    }
  ]
}
wmtdaxz3

wmtdaxz32#

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

{
    long_name: "California",
    short_name: "CA",
    types: [
        "administrative_area_level_1",
        "political"
    ]
}

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

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

wooyq4lh3#

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

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

退货

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "94040",
               "short_name" : "94040",
               "types" : [ "postal_code" ]
            },
            {
               "long_name" : "Mountain View",
               "short_name" : "Mountain View",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "Santa Clara County",
               "short_name" : "Santa Clara County",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "California",
               "short_name" : "CA",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            ...
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
回复:

{
"ResponseCode": 0,
"ResponseMessage": "OK",
"ResponseDateTime": "11/10/2014 8:17:20 AM GMT",
"Data": [
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Baroda House"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Bengali Market"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Bhagat Singh Market"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Connaught Place"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Constitution House"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Election Commission"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Janpath"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Krishi Bhawan"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Lady Harding Medical College"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "New Delhi",
        "Address": "New Delhi G.P.O."
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "North Avenue"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Parliament House"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Patiala House"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Pragati Maidan Camp"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Pragati Maidan"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Rail Bhawan"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Sansad Marg"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Sansadiya Soudh"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Secretariat North"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Shastri Bhawan"
    },
    {
        "Pincode": "110001",
        "Country": "INDIA",
        "City": "Central Delhi",
        "Address": "Supreme Court"
    }
]
}

相关问题