{
const container = DOM.element("div", {
style: `width:${width}px;height:${width / 1.6}px`
});
yield container;
const map = L.map(container).setView([37.7749, -122.4194], 12);
L.tileLayer("https://tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution:
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(map);
if (apiKey) {
const events = await fetchEvents();
events.results.forEach((event) => {
if (event.geo.geometry.type == "Point") {
const longitude = event.geo.geometry.coordinates[0];
const latitude = event.geo.geometry.coordinates[1];
L.marker([latitude, longitude])
.addTo(map)
.bindPopup(`${event.title} - ${event.start_local}`);
}
});
}
return container;
}