Public
Edited
Apr 14, 2023
Insert cell
Insert cell
Insert cell
map = {
const container = html`<div style="height:600px;">`;
yield container;
const map = L.map(container).setView([15, 27.6], 2);
//for more tile options see https://leaflet-extras.github.io/leaflet-providers/preview/ (copy url)
L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}{r}.png', {
attribution: "&copy; <a href=https://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
}).addTo(map);

// for marketCluster to work, you need to import the code snippet below to import this feature
let markers = markerCluster({});

// loop to create a marker for each drag queen
queen_geo.forEach(queen => {

var queenIcon = L.icon({
iconUrl: queen.contestant_image, // map to image url
iconSize: [32, 32], // size of the icon
iconAnchor: [16, 16], // point of the icon corresponds to marker's location
});

let marker = L.marker([queen.lat, queen.long], {icon: queenIcon});
// Add a tooltip with Queen info (name, hometown)
marker.bindTooltip(`<center><strong>${queen.contestant}</strong><br>${queen.location}<br>${queen.franchise_name}</center>`, {
permanent: false,
direction: 'top'
});
// Open the tooltip when the marker is clicked
marker.on('click', function() {
marker.openTooltip();
});
// Add the marker to the marker cluster group
markers.addLayer(marker);
});

// Add the marker cluster group to the map
map.addLayer(markers);


}



Insert cell
Insert cell
queen_geo.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
queenGeo.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
queen_geo_data.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
contestants.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
//get unique franchise names in a list for filter
franchises = [...new Set(contestants.map(f => f.franchise_name))]
Insert cell
queenList = [...new Set(queen_geo_data.map(q => q.name))].sort()
Insert cell
//subset data
scFiltered = contestants.filter(contestant => filters.franchise.includes(contestant.franchise_name) && contestant.season_year<=filters.seasonYear);
Insert cell
scFiltered[1].contestant_id
Insert cell
//
queenGeoFiltered = queen_geo_data.filter(queen => scFiltered.some(sc => sc.contestant_id === queen.contestant_id));

Insert cell
Insert cell
Insert cell
markerCluster = L, require('leaflet.markercluster@1.1.0').catch(() => L.markerClusterGroup)
Insert cell
Insert cell
Insert cell
// Template credit: This layout is updated from Martien van Steenbergen @martien/horizontal-inputs

template = (inputs) =>
htl.html`<div class="styled">${Object.values(inputs)}</div>
<style>
div.styled {
text-align: left;
column-count: 2
}
div.styled label {
font-weight: bold;
line-height: 200%;
}
div.styled label:not(div>label):after {
content: ":";
}
</style>`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more