2024-01-03 10:47:11 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="UTF-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
<title>Mapping Movements - Alternative map of movements</title>
|
|
|
|
<style>
|
2024-01-03 12:19:09 +00:00
|
|
|
:root {
|
2024-01-03 11:48:15 +00:00
|
|
|
--marker-size: 20px;
|
|
|
|
}
|
|
|
|
|
|
|
|
body {
|
|
|
|
background: linear-gradient(#e66465, #9198e5);
|
|
|
|
height: 100vh;
|
|
|
|
color: white;
|
|
|
|
font-family: sans-serif;
|
|
|
|
}
|
|
|
|
|
|
|
|
.about {
|
|
|
|
position: absolute;
|
|
|
|
bottom: 20px;
|
|
|
|
right: 20px;
|
|
|
|
width: 400px;
|
|
|
|
z-index: 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-01-03 10:47:11 +00:00
|
|
|
#map {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
}
|
|
|
|
|
2024-01-03 11:48:15 +00:00
|
|
|
.initiative::before {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
width: var(--marker-size);
|
|
|
|
height: var(--marker-size);
|
|
|
|
/* background: black; */
|
|
|
|
border: solid 2px black;
|
|
|
|
/* border-style: dotted; */
|
|
|
|
border-radius: 0 7px 0 7px;
|
|
|
|
content: ' ';
|
|
|
|
}
|
2024-01-03 12:19:09 +00:00
|
|
|
|
|
|
|
.initiative.selected::before,
|
|
|
|
.initiative:hover::before {
|
2024-01-03 11:48:15 +00:00
|
|
|
background: black;
|
|
|
|
}
|
|
|
|
|
2024-01-03 10:47:11 +00:00
|
|
|
.initiative {
|
|
|
|
position: absolute;
|
|
|
|
top: calc(50% - 50px);
|
|
|
|
left: 0;
|
2024-01-03 11:48:15 +00:00
|
|
|
/* height: 100px;
|
|
|
|
width: 100px; */
|
|
|
|
/* overflow: hidden; */
|
|
|
|
height: var(--marker-size);
|
|
|
|
width: var(--marker-size);
|
2024-01-03 10:47:11 +00:00
|
|
|
transition: left 2s, top 2s;
|
2024-01-03 11:48:15 +00:00
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
.initiative h2 {
|
|
|
|
position: absolute;
|
|
|
|
width: 250px;
|
|
|
|
font-size: 100%;
|
|
|
|
margin: 0;
|
|
|
|
/* opacity: .1; */
|
|
|
|
display: none;
|
|
|
|
top: calc(var(--marker-size) - 5px);
|
|
|
|
left: calc(var(--marker-size) + 10px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.initiative .organisation {
|
|
|
|
position: absolute;
|
|
|
|
width: 250px;
|
|
|
|
/* opacity: .1; */
|
|
|
|
display: none;
|
|
|
|
bottom: calc(var(--marker-size) - 5px);
|
|
|
|
left: calc(var(--marker-size) + 10px);
|
|
|
|
}
|
|
|
|
|
|
|
|
.initiative:hover .organisation,
|
|
|
|
.initiative:hover h2,
|
|
|
|
.initiative.selected .organisation,
|
|
|
|
.initiative.selected h2 {
|
|
|
|
opacity: 1;
|
|
|
|
display: block;
|
2024-01-03 10:47:11 +00:00
|
|
|
}
|
2024-01-03 12:19:09 +00:00
|
|
|
|
|
|
|
svg {
|
|
|
|
|
|
|
|
position: fixed;
|
|
|
|
top: 40px;
|
|
|
|
left: calc(20px + var(--marker-size) / 2);
|
|
|
|
right: 0;
|
|
|
|
height: calc(100vh - 100px);
|
|
|
|
z-index: -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
svg line {
|
|
|
|
stroke: rgba(255, 255, 255, .5);
|
|
|
|
stroke-width: 0.3px;
|
|
|
|
stroke-dasharray: 100 100;
|
|
|
|
stroke-dashoffset: 0;
|
|
|
|
transition: stroke-dashoffset 2s, opacity 2s;
|
|
|
|
}
|
2024-01-03 10:47:11 +00:00
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
class Map {
|
2024-01-03 12:19:09 +00:00
|
|
|
constructor(mapEl, lineEl) {
|
|
|
|
this.margin = 20;
|
2024-01-03 11:48:15 +00:00
|
|
|
|
2024-01-03 10:47:11 +00:00
|
|
|
this.mapEl = mapEl;
|
2024-01-03 12:19:09 +00:00
|
|
|
this.lineEl = lineEl;
|
2024-01-03 10:47:11 +00:00
|
|
|
this.initiatives = []
|
|
|
|
this.similarities = {}
|
2024-01-03 11:48:15 +00:00
|
|
|
this.offsets = []
|
2024-01-03 12:19:09 +00:00
|
|
|
this.offsetsEls = {}
|
|
|
|
|
2024-01-03 11:48:15 +00:00
|
|
|
|
2024-01-03 10:47:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_load() {
|
|
|
|
|
|
|
|
return fetch("similarities.json")
|
|
|
|
.then((response) => {
|
|
|
|
if (!response.ok) {
|
|
|
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
return response.json();
|
|
|
|
})
|
|
|
|
.then((response) => {
|
|
|
|
this.initiatives = response.initiatives
|
|
|
|
this.similarities = response.similarities
|
2024-01-03 11:48:15 +00:00
|
|
|
this.offsets = response.pca_1
|
2024-01-03 10:47:11 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this._load()
|
|
|
|
.then(() => {
|
|
|
|
this._createElements()
|
|
|
|
this.selectInitiative(0)
|
2024-01-03 11:48:15 +00:00
|
|
|
|
|
|
|
window.addEventListener('resize', (e) => this.selectInitiative(this.selectedIndex))
|
2024-01-03 10:47:11 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_createElements() {
|
|
|
|
this.mapEl.innerHMTL = "";
|
|
|
|
this.initiatives.forEach((initiative, initiative_idx) => {
|
|
|
|
const el = document.createElement('div')
|
|
|
|
el.classList.add('initiative')
|
|
|
|
el.innerHTML = `
|
|
|
|
<h2>${initiative.Title}</h2>
|
|
|
|
<div class='organisation'>${initiative.Organisation}</div>
|
|
|
|
`;
|
|
|
|
el.addEventListener('click', (e) => this.selectInitiative(initiative_idx));
|
|
|
|
initiative['el'] = el;
|
|
|
|
this.mapEl.appendChild(el);
|
2024-01-03 12:19:09 +00:00
|
|
|
|
|
|
|
// <line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
|
|
|
|
const line = document.createElementNS("http://www.w3.org/2000/svg", 'line')
|
|
|
|
line.setAttributeNS(null, "x1", 0)
|
|
|
|
line.setAttributeNS(null, "y1", 0)
|
|
|
|
line.setAttributeNS(null, "x2", Math.cos(this.offsets[initiative_idx] * Math.PI - Math.PI * .5) * 100)
|
|
|
|
line.setAttributeNS(null, "y2", Math.sin(this.offsets[initiative_idx] * Math.PI - Math.PI * .5) * 100)
|
|
|
|
|
|
|
|
this.lineEl.appendChild(line);
|
|
|
|
this.offsetsEls[initiative_idx] = line;
|
2024-01-03 10:47:11 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
selectInitiative(nr) {
|
|
|
|
this.selectedIndex = nr;
|
|
|
|
this.selectedInitiative = this.initiatives[nr];
|
|
|
|
|
2024-01-03 11:48:15 +00:00
|
|
|
const radius = Math.min(window.innerWidth, window.innerHeight / 2) - 2 * this.margin;
|
|
|
|
const centerY = window.innerHeight / 2 - this.margin;
|
|
|
|
const centerX = this.margin;
|
|
|
|
|
2024-01-03 10:47:11 +00:00
|
|
|
this.similarities[this.selectedIndex].forEach((similarity, initiative_idx) => {
|
2024-01-03 11:48:15 +00:00
|
|
|
const offset = this.offsets[initiative_idx] // initiative_idx / (this.initiatives.length - 1);
|
2024-01-03 10:47:11 +00:00
|
|
|
const el = this.initiatives[initiative_idx]['el'];
|
2024-01-03 11:48:15 +00:00
|
|
|
const r = (similarity - 1) * radius;
|
|
|
|
const x = Math.cos(offset * Math.PI + Math.PI * .5) * r
|
|
|
|
const y = Math.sin(offset * Math.PI + Math.PI * .5) * r
|
|
|
|
|
|
|
|
if (this.selectedIndex == initiative_idx) {
|
|
|
|
el.classList.add('selected');
|
2024-01-03 12:19:09 +00:00
|
|
|
el.style.top = `${centerY}px`;
|
|
|
|
el.style.left = `${centerX}px`;
|
2024-01-03 11:48:15 +00:00
|
|
|
} else {
|
2024-01-03 12:19:09 +00:00
|
|
|
el.style.top = `${centerY + y}px`;
|
|
|
|
el.style.left = `${centerX + x}px`;
|
2024-01-03 11:48:15 +00:00
|
|
|
el.classList.remove('selected')
|
|
|
|
}
|
2024-01-03 12:19:09 +00:00
|
|
|
|
|
|
|
this.offsetsEls[initiative_idx].style.strokeDashoffset = similarity * 100;
|
|
|
|
this.offsetsEls[initiative_idx].style.opacity = similarity;
|
2024-01-03 10:47:11 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var map;
|
|
|
|
document.addEventListener("DOMContentLoaded", (event) => {
|
2024-01-03 12:19:09 +00:00
|
|
|
map = new Map(document.getElementById('map'), document.getElementById('lines'));
|
2024-01-03 10:47:11 +00:00
|
|
|
map.init()
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
<div class="about">This map was created by Ruben van de Ven for the <em>Mapping Movements</em> pressure cooker,
|
|
|
|
organised by Creative Coding Utrecht for the Copernicus Institute of the Utrecht University.</div>
|
|
|
|
<div id="map"></div>
|
2024-01-03 12:19:09 +00:00
|
|
|
<svg reserveaspectratio="xMinYMid meet" viewBox="0,-100,200,200" id="lines"></svg>
|
2024-01-03 10:47:11 +00:00
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|