Google maps - either lat and long or postcode
<p>I have the following code to display markers on a google map based upon an array of locations, however I have a mix of postcodes and Lat/longs, I've used the geocoder to convert the postcodes to lat/longs but can't then use them when I try and set a marker.</p>

<p>Thanks for any help!</p>

<pre><code>var geocoder;  
var map;  
var pos;  
var geoLat;  
var geoLong;  
var markers = [];  
var bounds = new google.maps.LatLngBounds();  
var locations = [  
    [null, 'London Eye, London', 51.503454,-0.119562, 4]  
    ,[null, 'Palace of Westminster, London', 51.499633,-0.124755]  
    ,[null, 'The London Dungeon', 'SE1 7PB', ,  2]  //Value with Postcode
];  

function isNumber(o) { return ! isNaN (o-0) &amp;&amp; o !== null &amp;&amp; o !== "" &amp;&amp; o !== false; }  

function init() {  
  geocoder = new google.maps.Geocoder();  
  var num_markers = locations.length;  

  map = new google.maps.Map(document.getElementById('map_canvas'), {  
    zoom: 10,  
    center: new google.maps.LatLng(locations[0][2], locations[0][3]),  
    mapTypeId: google.maps.MapTypeId.ROADMAP   
  });  

  for (var i = 0; i &lt; num_markers; i++) {  
    if (isNumber (locations[i][2]) &amp;&amp; isNumber (locations[i][3])){  
      geoLat = locations[i][2]  
      geoLng  = locations[i][3]  
      alert(typeof(geoLat) +' '+typeof(geoLng))  //generates a correct  number number response
    }else{  
      geocoder.geocode( { 'address': locations[i][2]}, function(results, status) {  
        if (status == google.maps.GeocoderStatus.OK) {  
          geoLat = results[0].geometry.location.lat()  
          geoLng = results[0].geometry.location.lng()  
          alert(typeof(geoLat) +' '+typeof(geoLng))   //generates a correct  number number response 
        }  
      });  
    }  

    pos = new google.maps.LatLng(geoLat, geoLng);  // Doesn't get value if a geocodes postcode added in
    bounds.extend(pos);  
    map.fitBounds(bounds);  

    markers[i] = new google.maps.Marker({  
      position: pos,  
      map: map,  
      id: i,  
      title: locations[i][1]  
    });  
  }  
}  

    google.maps.event.addDomListener(window, 'load', init);
</code></pre>