I am trying to display a title in each markers info window that will display the name of the event. Right now I only can display the very last elements name in the JSON array, and am unsure how to make the others their event title. Any help is appreciated, thanks! I would also like to eventually show along with the event name a couple other elements such as "eventPhone" etc...
The info window only showing last element:
what the array looks like:
my add marker function:
addMarkersMap(markers){
for(let marker of markers)
{
var loc = marker.calEvent.locations[0]['coords'];
var name = marker.calEvent['eventName'];
console.log(name); //displays name of each event within this object
marker = new google.maps.Marker({
position: loc,
map: this.map,
});
var infoWindow = new google.maps.InfoWindow({
//content: name
});
google.maps.event.addListener(marker, 'click', function() {
infoWindow.open(this.map, marker);
infoWindow.setContent(name);
});
}
}
JSON:
http://app.toronto.ca/cc_sr_v1_app/data/edc_eventcal_APR?limit=500
' + name +'
'+ 'website: ' + eventWebsite + '
'` You can also add classes to the html or however you want to manipulate it. Learn more about it here in the [documentation](https://developers.google.com/maps/documentation/javascript/examples/infowindow-simple) – syciphj Oct 27 '17 at 03:56