function attach_info_window(map, marker, events, infowindow) {

	/*
	 * https://developers.google.com/maps/documentation/javascript/infowindows
	 * https://stackoverflow.com/questions/11106671/google-maps-api-multiple-markers-with-infowindows
	 */

	let window_content = '<div id="info_window">';
	for (key in events) {
		if (key > 0)
			window_content += `<hr />`;
		let presence = "en ligne";
		if (events[key].irl)
			presence = "en presentiel";
			
		window_content += `
			<p>
				${events[key].title}
			</p>
			<p>
				${presence}
			</p>
		`;
	};
	window_content += '</div>';

	marker.addListener('click', () => {

		let view_center = map.getCenter();
		let marker_position = marker.getPosition();
		console.log("marker position: " + marker_position);
		let window_position = view_center;

		infowindow.setOptions({
			//disableAutoPan: true,
			disableAutoPan: false,
			content: window_content,

			/* dimensions */
			//maxWidth: 400,
			//minWidth: 400,

			/* center window */
			position: window_position,

			/* center window */
			//position: (map.getCenter()),
			//pixelOffset: { width: 50, height: 50 },

			//shouldFocus: false,
		});

		infowindow.open(map);
	});

}
