0

I am not a javascript programmer but I need to use some to plot about 30-40 postcodes onto Google Maps. I have the code below but the number of markers that are plotted are a little random but normally it's 3 or 10. From what I have read this could be a timeout issue with Google and I need to set a delay between each reads. The Post Codes are not in an array but being read in from a database. Seems to load upto the first 10 Post Codes only.

The examples I have seen include an array of the addresses into the JavaScript and a delay between each address. Mine are coming from a data source so I need some assistance with adapting the code I have below.

Can anybody help at all? Thanks in advance

<script type="text/javascript" `src="http://maps.google.com/maps/api/js?sensor=false"></script>


<div id="map" style="width: 700px; height: 800px"></div>


<script type="text/javascript">

var latlng = new google.maps.LatLng(40.756, -73.986);


var options = {
center : latlng,
zoom : 6,
mapTypeId : google.maps.MapTypeId.ROADMAP
};


// Creating the map


var map = new google.maps.Map(document.getElementById('map'), options);


var geocoder = new google.maps.Geocoder();

function AddMarker(address) 
{
geocoder.geocode( {'address' : address}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK) 
    {
    map.setCenter(results[0].geometry.location);
    var marker = new google.maps.Marker( 
        {
         map : map,
         position : results[0].geometry.location
        });

    var infowindow;
    if (!infowindow) 
        {
         infowindow = new google.maps.InfoWindow();
         }

     infowindow.setContent(address);
     google.maps.event.addListener(marker, 'mouseover', function()
    { 
    infowindow.open(map,marker); 
    });
    google.maps.event.addListener(marker, 'mouseout', function()
        {
                infowindow.close(); 
        });

    }


});


}


</script>
Nav
  • 9
  • 2

0 Answers0