What could be the best way to get location for a given zipcode. Would it work for countries outside US/Canada .Thanks
-
You can find location by providing the address of that location – Aditya Jan 10 '11 at 11:17
-
For future reference pleas refer to here:- http://stackoverflow.com/questions/9606031/ios-mkmapview-place-annotation-by-using-address-instead-of-lat-long – StuartM May 03 '14 at 12:34
3 Answers
Use the Google geolocating API (try it out on google.com/maps):
Input for a Swiss ZIP code for example: CH-9014
or a french one: FR-34000
or german: de-12101
or US: us-90210
or canada: ca-J5Z 1A1
or china: cn-100000
for example:
yields
{
"status": "OK",
"results": [ {
"types": [ "postal_code" ],
"formatted_address": "9014 St Gallen, Switzerland",
"address_components": [ {
"long_name": "9014",
"short_name": "9014",
"types": [ "postal_code" ]
}, {
"long_name": "St Gallen",
"short_name": "St Gallen",
"types": [ "locality", "political" ]
}, {
"long_name": "Sankt Gallen",
"short_name": "SG",
"types": [ "administrative_area_level_1", "political" ]
}, {
"long_name": "Switzerland",
"short_name": "CH",
"types": [ "country", "political" ]
} ],
"geometry": {
"location": {
"lat": 47.4082855,
"lng": 9.3323890
},
"location_type": "APPROXIMATE",
"viewport": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
},
"bounds": {
"southwest": {
"lat": 47.3991076,
"lng": 9.3180504
},
"northeast": {
"lat": 47.4199564,
"lng": 9.3543340
}
}
}
} ]
}
So the swiss ZIP code 9014 corresponds appx. to this location:
"lat": 47.4082855,
"lng": 9.3323890
See my answer on the geolocating API here:
How to get GLatLng object from address string in advance in google maps?

- 1
- 1

- 78,642
- 66
- 377
- 442
-
@Jagdish: My code? Yes. The google-api for commercial intranet purposes: no. – Stefan Steiger Mar 19 '14 at 15:10
GeoNames offers a number of various zipcode geocoding services, including search for the location of a given zipcode. They support a number of various countries.
You would probably be most interested in the Placename Lookup for postalcode service

- 9,212
- 2
- 29
- 38
-
I just found this [site](http://download.geonames.org/export/zip/) on GeoNames. It offers files for different countries with the mapping of the zip code to the lan/long values. Now, I can create a batch process and store all required values in my database, being able to loop up lat/long values for a given zip code. Thanks you :) – kon Oct 16 '12 at 16:43
Google's API comes with some fairly nasty restrictions. Better to use open sources like GeoNames per @Claus Broch's suggestion.
I'm adding this answer to also note that MapQuest has recently put up an API to OpenStreetMap data. It doesn't do (as far as I can tell) zip code searching, but location names, directions, altitude etc are all freely queryable. I recently discovered it an I plan on replacing my calls to google maps API with it as soon as I can.

- 21,623
- 6
- 63
- 87
-
-
There are limits on the number of calls you can make in a day, is one. The bigger deal is, you are only allowed to use their api in conjunction with showing a Google Map. So using it purely in the background as the data-gathering tool it is isn't allowed. – Dan Ray Jan 11 '11 at 12:59