Example:
Using a JS object to draw a collection of markers, taking the position and additional attributes from the object itself.
On each loop the marker is drawn, and it receives a click listener, which in turn opens an infowindow whose content is the markers properties, taken from the JS object.
Made as an example for Stack Overflow