Google Geocoder

Posted on 2012-08-31
Last Modified: 2012-09-01
Dear Experts

I am using the code below to plot a google map.  As you will see I am using the lat and long values which I have in this instance.

'function initialize()
      // Make an instance of Geocoder
      geocoder = new google.maps.Geocoder();
      // Set static latitude, longitude value
var latlng = new google.maps.LatLng(<%=(residential.Fields.Item("pLat").Value)%>, -<%=(residential.Fields.Item("pLong").Value)%>);

      // Set map options
      var myOptions = {
            zoom: 17,
            center: latlng,
            panControl: true,
            zoomControl: true,
            scaleControl: true,
            mapTypeId: google.maps.MapTypeId.ROADMAP
      // Create map object with options
      map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
      // Create and set the marker
      marker = new google.maps.Marker({
            map: map,
            position: latlng
      // Register Custom "dragend" Event
      google.maps.event.addListener(marker, 'dragend', function() {
            // Get the Current position, where the pointer was dropped
            var point = marker.getPosition();
            // Center the map at given point
            // Update the textbox
            document.getElementById('txt_lng').value=point.lng()* -1;

I am trying to achieve the same except this time I do not have the lat and long values but only the postcode.

Can anyone suggest what changes I need to the above to geocode the postcode and give me the same output.

Many thnaks for any help

Question by:grantballantyne
    LVL 81

    Expert Comment

    LVL 25

    Accepted Solution

    Example attached.

    Author Comment

    Thanks lwadwell

    Thats is almost exactly what I need.

    Please see the following :

    Do you know how I can make the values appear in the form boxes?

    Many thanks

    Author Comment


    Thanks again.

    Please ignore previous question - I managed to work it out.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    The viewer will learn how to count occurrences of each item in an array.
    Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now