I'm trying to run through a loop in Wordpress and for each item in the loop I need to geocode the address, then add the LatLng into an array. I think I have it coded right but it will not work. Here is the code:
<script type="text/javascript">
var locs = []
function initialize() {
var geo = new google.maps.Geocoder;
var address = "<?php echo $arrayAddress; ?>";
geo.geocode({'address':address},function(results, status){
if (status == google.maps.GeocoderStatus.OK) {
var myLatLng = results[0].geometry.location;
locs.push(myLatLng);
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
I've verified that the myLatLng variable does contain the lat and long like it should. I just can't get it to push it into the variable. Is this some simple syntax I've missed?