Rick,
Thanks so much for the info. I've been looking at this code, which was
designed for Excel. Do you think I could modify this to work for my
ASP page?

Const MYKEY = "your_key_goes_here"

Sub BatchGeocode()
    With Sheets(1)
        r = 2
        Do While .Cells(r, 1) <> ""
            .Cells(r, 2) = getzip(.Cells(r, 1).Value)

            'the next 4 lines ensure that we don't abuse Google by
querying them too fast
            t = Timer
            Do While Timer < t + 0.3
                DoEvents
            Loop

            r = r + 1
        Loop

    End With

    MsgBox "Done getting zips"
End Sub


Function getzip(myAddress As String) As String
myAddress = Replace(myAddress, " ", "+")
myURL = "http://maps.google.com/maps/geo?q="; & myAddress &
"&output=xml&oe=utf8&sensor=false&key=" & MYKEY
Dim objHttp As Object
Set objHttp = CreateObject("MSXML2.ServerXMLHTTP")
Call objHttp.Open("GET", myURL, False)
Call objHttp.Send("")
Results = objHttp.ResponseText

sloc = InStr(Results, "<PostalCodeNumber>") + Len
("<PostalCodeNumber>")
eloc = InStr(sloc, Results, "</PostalCodeNumber>")
If eloc > sloc Then getzip = Mid(Results, sloc, eloc - sloc) Else
getzip = ""

End Function

LMK. Thanks! Ogún

On Aug 24, 12:36 pm, Rick <[email protected]> wrote:
> I think what you need is a service that gives you the zip code list in
> a city. As far as I know, Google Map API does not provide this
> function, but there are several other resources meet your requirement,
> such as geoNames or dyngeometry. Take a look at this:
>
> http://www.dyngeometry.com/WebServiceV2/GeometryInfo.asmx?op=GetCityN...http://www.dyngeometry.com/web/Address.aspx
>
> You need ajax or json to call the service if you don’t want your page
> refresh.
> Hope this is helpful and good luck!
>
> On Aug 24, 12:07 pm, Ogún Niké <[email protected]> wrote:
>
>
>
> > Hi all,
> > I'm totally new to the API so please pardon any ignorance here. I've
> > searched to see if I could answer my own question but no luck...
>
> > I have a form wherein a user will input an address consisting of
> > street address, city and state. I need my form to auto-populate the
> > zip code, ideally without submitting or refreshing the page. This
> > will, in turn, trigger other values on the page (zone number and
> > related fees for transport.) In other words, as Form.City field gets
> > onChange, Form.ZipCode will be populated.
>
> > Is this possible? Please advise. Many thanks! Ogún.- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" 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-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to