After I add info windows to my pin array, when I click on the second pin the infowindow
pops up over the first pin. And when I click on the first pin the second pin's infowindow
pops up.
This is the pin array:
function setMarkers(map) {
// Adds markers to the map.
var image = {
url: 'http://localhost:8888/wp-content/plugins/wp_cat_map/assets/img/home_pin.png',
size: new google.maps.Size(35, 42),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(0, 42)
};
var shape = {
coords: [0, 0, 35, 42],
type: 'rect'
};
for (var i = 0; i < thePins.length; i++) {
var pin = thePins[i];
var contentString = pin[0];
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200
});
var marker = new google.maps.Marker({
position: {lat: pin[1], lng: pin[2]},
map: map,
icon: image,
//shape: shape,
title: pin[0],
zIndex: pin[3]
});
marker.addListener('click', function() {
infowindow.open(map, marker);
});
}
}