GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
State / province available from postalCodeLookupJSON  XML
Forum Index -> Administrative Divisions
Author Message
robrichard



Joined: 24/07/2008 03:32:18
Messages: 2
Offline

GeoNames - first of all, I want to thank you for the service! It's excellent!

I wanted to know if there is a way to get state/province from postalCodeLookupJSON (or could I perhaps use findNearbyPostalCodesJSON?) I'm using the javascript code posted on the site to populate placeName from a postal code and wanted to also have state/province populated if it were appropriate.

Thanks!
robrichard



Joined: 24/07/2008 03:32:18
Messages: 2
Offline

You have to like it when you answer your own questions. The answer to the question is that, at least for postal codes in the US, the state is available. Using the following javascript line as the request:

Code:
request = 'http://ws.geonames.org/findNearbyPostalCodesJSON?postalcode=' + postalcode  + '&country=' + country  + '&radius=0&callback=getLocation';


we are able to extract the state abbreviation using:

Code:
 var txtState = document.getElementById("txtState");
 txtState.value = postalcodes[0].adminCode1;


Cheers to anyone who needed that info!

robrichard
 
Forum Index -> Administrative Divisions
Go to:   
Powered by JForum 2.1.5 © JForum Team