I\'ve got a working section of google maps javascript, I did have a problem.
Now the issue I had was that only one infowindow was showing up, the la
For some reason, I had to modify marker object and access that data inside event lisener function.
Scope of click event fuction on marker is marker object.
var infowindow = new google.maps.InfoWindow();
for(int i = 0; i < locations.length; i++){
var latLng = new google.maps.LatLng(locations[i][1], locations[i][2]);
var contentString = locations[i][0];
marker = new google.maps.Marker({
position: latLng,
map: map,
contentString: contentString
});
marker.data = locations[i]; // adds object to marker object
marker.addListener('click', function() {
// read custom data in this.data
infowindow.setContent(""+ this.data[0] +"");
infowindow.open(map, this);
map.setCenter(this.getPosition());
});
}