correction
function findZipCode(address,callback) {
geocoder.getLocations(
address,
function(response) {
if (!response || response.Status.code != 200) {
callback(zip);
}
else {
var zip;
if (typeof(response.Placemark
[0].AddressDetails.Country.AdministrativeArea.Locality) ==
"undefined")
zip = response.Placemark
[0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
else
zip = response.Placemark
[0].AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber;
callback(zip);
}
}
)
}
On Aug 20, 7:33 pm, Artem Sav <[email protected]> wrote:
> Here's the code for anyone interested, geocoder is my global geocoding
> object defined as:
> var geocoder = new GClientGeocoder();
>
> function findZipCode(address,callback) {
> geocoder.getLocations(
> address,
> function(response) {
> if (!response || response.Status.code != 200) {
> callback("");
> }
> else {
> var zip;
>
> if (response.Placemark
> [0].AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber
> == null)
> zip = response.Placemark
> [0].AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber;
> else
> zip = response.Placemark
> [0].AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber;
>
> callback(zip);
> }
> }
> )
>
> }
>
> On Aug 20, 7:03 pm, Jeremy Geerdes <[email protected]> wrote:
>
> > Actually, you can use the GMaps geocoding service to get postal code
> > information. Check out the documentation here:
>
> >http://code.google.com/apis/maps/documentation/geocoding/
>
> > And an example of the JSON response (look for the PostalCode portion
> > near the top) here:
>
> >http://maps.google.com/maps/geo?q=1600+Amphitheatre+Parkway,+Mountain...
>
> > Jeremy R. Geerdes
> > Effective website design & development
> > Des Moines, IA
>
> > For more information or a project
> > quote:http://jgeerdes.home.mchsi.comhttp://jgeerdes.blogspot.comhttp://jgee...
> > [email protected]
>
> > Unless otherwise noted, any price quotes contained within this
> > communication are given in US dollars.
>
> > If you're in the Des Moines, IA, area, check out Debra Heights
> > Wesleyan Church!
>
> > And check out my blog, Adventures in Web Development,
> > athttp://jgeerdes.blogspot.com
> > !
>
> > On Aug 20, 2009, at 5:56 PM, Artem Sav wrote:
>
> > > Hi,
> > > I haven't found anything on google or in this group.
>
> > > I am using limited local search to find businesses around particular
> > > coordinate.
> > > LocalSearch returns pretty good results in the GsearchResultClass
> > > structure - name of business, address, city, state and phone.
> > > Anything missing? Well, yes, the zip code. Why is it not included?
>
> > > Same issue with Google Maps geocoder obviously - it doesn't include
> > > postal code if you do geocoding of an address, see xml data
> > > transmitted here for example:
> > >http://code.google.com/apis/maps/documentation/examples/geocoding-sim...
>
> > > It does make some degree of sense in case of Maps (zip being an
> > > artificial thing), but in case of Local Search it makes very little
> > > sense - these addresses come from yellow pages and as such do carry
> > > that info in the original data source.
>
> > > I guess my question is if there is any web service API from Google
> > > which i could use to find postal code of an address/coordinate. I can
> > > already do the reverse (just put the zip in the above geocoding
> > > example)
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google AJAX APIs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en
-~----------~----~----~----~------~----~------~--~---