Google Maps Api

Discussion in 'Javascript' started by H.Schmidt, Aug 5, 2008.

  1. H.Schmidt

    H.Schmidt Guest

    Hi!

    im would like to get address informations like city, state or zip for a
    given GPoint. Is it possible (i found nothing in Google maps Api)?

    Thanks in advance
     
    H.Schmidt, Aug 5, 2008
    #1
    1. Advertisements

  2. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title>Search Country, City, State, Address with GPoint</title>
    <script type="text/javascript"
    src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;key=[XX]">
    </script>
    <script type="text/javascript"
    src="http://google.com/uds/api?file=uds.js&amp;v=1.0">
    </script>
    <script type="text/javascript"
    src="http://google.com/uds/solutions/localsearch/gmlocalsearch.js">
    </script>
    <script type="text/javascript">
    function findInfo(x,y) {
    if (GBrowserIsCompatible()) {
    var s = new GlocalSearch();
    var c = {
    callback:function() {
    if(s.results.length == 0) {
    alert('No result');
    }
    else {
    alert('Country: ' + s.results[0].country);
    alert('City: ' + s.results[0].city);
    alert('State: ' + s.results[0].region);
    alert('Address: ' + s.results[0].streetAddress);
    }
    }
    };
    s.setCenterPoint(new GLatLng(x,y), 1);
    s.setSearchCompleteCallback(c, c.callback);
    s.execute(new GLatLng(0,0), 1);
    }
    }
    </script>
    </head>
    <body onunload="GUnload()">
    <b>GPoint coordinates</b><br>
    X: <input type="text" value="40.014" id="X" name="X"><br>
    Y: <input type="text" value="0.846" id="Y" name="Y"><br>
    <input type="button" value="Go"
    onClick="findInfo(document.getElementById('X').value,
    document.getElementById('Y').value);">
    </body>
    </html>

    -------------------------------------------------------------------

    Info:
    http://code.google.com/apis/maps/documentation/reference.html
    http://code.google.com/apis/ajaxsearch/documentation/reference.html#_class_GlocalResult
    (apparently there is no property for the ZIP-code)

    Replace [XX] by your Maps API Key

    Hope this helps,
     
    Bart Van der Donck, Aug 5, 2008
    #2
    1. Advertisements

  3. H.Schmidt

    H.Schmidt Guest

    Many Thanks!
     
    H.Schmidt, Aug 6, 2008
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.