83 lines
1.7 KiB
JavaScript
83 lines
1.7 KiB
JavaScript
|
|
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="infowindow_limits">
|
|
<div class="infowindow">
|
|
<div class="infowindow_head">
|
|
<p>${events[0].location.address}</p>
|
|
<div id="infowindow_close" onclick="g_infowindow.close()"></div>
|
|
</div>
|
|
`;
|
|
for (key in events) {
|
|
window_content += `
|
|
<a class="infowindow_body" href="${events[key].url}">
|
|
<p>${events[key].title}</p>
|
|
</a>
|
|
`;
|
|
};
|
|
window_content += `
|
|
</div>
|
|
</div>
|
|
`;
|
|
|
|
marker.addListener('click', () => {
|
|
|
|
let view_center = map.getCenter();
|
|
// height must be half css value (mp_info_windows.css -> '--size: XXXpx;')
|
|
let window_offset = { width: 0, height: 275 };
|
|
|
|
infowindow.setOptions({
|
|
//disableAutoPan: true,
|
|
disableAutoPan: false,
|
|
content: window_content,
|
|
|
|
/* dimensions */
|
|
//maxWidth: 400,
|
|
//minWidth: 400,
|
|
|
|
/* center window */
|
|
position: view_center,
|
|
pixelOffset: window_offset,
|
|
|
|
//shouldFocus: false,
|
|
});
|
|
|
|
infowindow.open(map);
|
|
});
|
|
|
|
}
|
|
|
|
/*
|
|
event : {}
|
|
- heure_de_debut : "";
|
|
- heure_de_fin : "";
|
|
- categorie : "";
|
|
- date : "";
|
|
- pays : "";
|
|
- ville : "";
|
|
- adresse : "";
|
|
- prenom : "";
|
|
- nom : "";
|
|
- irl : bool;
|
|
- id : x;
|
|
- index : x (default null);
|
|
- title : "";
|
|
- url : "";
|
|
- location : {}
|
|
- street : "";
|
|
- city : "";
|
|
- country : "";
|
|
- address : "";
|
|
- approximate : bool;
|
|
- coordinates : {}
|
|
- lat : x;
|
|
- lng : x;
|
|
*/
|
|
|