2014-11-10 3 views
2

В моем приложении я получаю код страны и почтового индекса. Используя эти два поля, я хочу получить имя штата и имя города или деревни. Есть ли какой-либо API, доступный для получения этих данных, спасибоApi Чтобы получить Местоположение с помощью почтового индекса

ответ

8

Вы можете использовать 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" 
    ] 
} 

Но обратите внимание, что свободный уровень будет поддерживать только:

  • 2500 запросов в 24-часовой период.
  • 5 запросов в секунду.
+1

Спасибо ... –

+1

Спасибо, Это работает и для Индии ..... –

2

может помочь

https://www.whizapi.com/open-api/api-details?id=20

url->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" 
    } 
] 
} 
+0

есть ли какой-либо ключ api для целей тестирования, если да PLZ предоставить мне еще это api работает с любым pincode? – Dilip

1

Если вы используете геокодер 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" ] 
      }, 
      ... 
Смежные вопросы