I\'m having problems with making multiple markers appear on my Google Map. I\'ve been trying stuff from all over the internet but most of the time the map just breaks.
E
Let's say you have an array of LatLng objects call latLngs
and that you wanted a marker for each of those objects. You might do it something like this (taking the tail end of your code in your question and modifying it):
var markers = new Array(latLngs.length);
for (var i = 0; i < markers.length; i++) {
markers[i] = new google.maps.Marker({
position: latLngs[i],
title:"Marker "+i,
icon: image,
shadow: shadow,
map: map,
shape: shape
});
markers[i].setMap(map);
}
The main thing is that you can't reuse your marker
variable. You need to use a different variable for each marker, hence the array.