map = {
let container = DOM.element("div", {
style: `width:${width}px;height:${width / 1.6}px`
});
yield container;
let map = L.map(container).setView([37.7881014522033, -122.420267712778], 13);
let osmLayer = L.tileLayer(
'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
).addTo(map);
if (observations.length) {
observations.forEach(observation => {
let markerHtmlStyles = `
background-color: ${rgbForDate(observation.observed_on)};
width: 7px;
height: 7px;
display: block;
border-radius: 50%;
border: 1px solid #FFFFFF`;
let title = JSON.stringify(observation);
let icon = L.divIcon({
className: "my-custom-pin",
html: `<span style="${markerHtmlStyles}" />`
});
if (observation.geojson) {
let marker = L.marker(
L.latLng(observation.geojson.coordinates[1], observation.geojson.coordinates[0]),
{
title: title,
icon: icon
}
).addTo(map);
marker.bindPopup(rgbForDate(observation.observed_on) + ' ' + observation.observed_on);
}
});
}
}