-1

I am trying to add pins to a map I am creating for my website.

The html code only give me a maximum of 4 pins, so far I have tried to add 6 but there is more to come, can someone please tell me how to fix it?

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>Google Maps Multiple Markers</title> 
  <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCHLqk7ajEQviaeDoaEOiYvxWAtuATm5oY&callback=initMap">
          type="text/javascript"></script>
</head> 
<body>
  <div id="map" style="width: 600px; height: 600px;"></div>

  <script type="text/javascript">
    var locations = [
      ['Stolford Beach Stogursey TA51TW', 51.207404, -3.099290, 1],
      ['Lilstock Beach, Lillstock TA51SU', 51.201793,  -3.186663, 2],
      ['Kilve Beach, Kilve TA51EG', 51.192534, -3.227412, 3],
      ['<p>East Quantoxhead Beach</p> <p>East Quantoxhead TA51EJ 5Mins- Accesible from kilve at low tide (14:30)</p>', 51.190542, -3.238637, 4],
      ['St Andries Bay, West Quantoxhead TA4 4DY', 51.181029, -3.272607, 5]
      ['Doniford Beach, Doniford TA230TL', 51.179679, -3.308254, 6]
    ];

    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 9,
      center: new google.maps.LatLng( 50.858026, -3.392425),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();
maxWidth: 200
    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map
      });

      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);

          infowindow.open(map, marker);

        }
      })(marker, i));
    }
  </script>
</body>
</html>
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189

1 Answers1

0

Please have a close look at where you initialize var locations. You forgot the , behind those nested arrays after the fourth element.

Further remove &callback=initMap from the URL in line six as it causes an error.

Hope it helps!

M.S.
  • 312
  • 1
  • 12