Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 54 additions & 99 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"eslint:fix": "eslint --fix src/**/*.{css,ts} cities.json"
},
"dependencies": {
"maplibre-gl": "^5.24.0"
"maplibre-gl": "^6.4.1"
}
}
19 changes: 10 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
'use strict';

import { LngLatLike, Map, Popup } from 'maplibre-gl';
import { LngLatLike, Map, Popup, setWorkerUrl } from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
import points from './cities-point.json';
import polygons from './cities.json';

setWorkerUrl(new URL('../node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url).toString());

const countElement = document.getElementById('count');
if (typeof countElement !== 'undefined' && countElement !== null) {
countElement.innerText = polygons.features.length.toString();
Expand Down Expand Up @@ -91,20 +93,19 @@ map.on('load', () => {
}
}

const { name, url, statistics } = event.features[0].properties as { name: string; url: string; statistics: string };
const stats = JSON.parse(statistics) as Record<string, number>;
const { name, url, statistics } = event.features[0].properties as { name: string; url: string; statistics: Record<string, number> };

const total = Object.values(stats).reduce((a, b) => a + b, 0);
const totalPerson = total - stats['-'];
const total = Object.values(statistics).reduce((a, b) => a + b, 0);
const totalPerson = total - statistics['-'];

const html = `${name}<br><a target="_blank" href="${url}">${url}</a>` +
'<div style="border-top: 1px solid #000; font-size: small; padding-top: 5px; margin-top: 5px; white-space: nowrap;">' +
`Out of ${total} street names,<br>${totalPerson} have been found to be named after a person :` +
'<ul style="margin: 0; padding-left: 15px;">' +
(stats.F > 0 ? `<li>${stats.F} after a cisgender female</li>` : '') +
(stats.FX > 0 ? `<li>${stats.FX} after a transgender female</li>` : '') +
(stats.MX > 0 ? `<li>${stats.MX} after a transgender male</li>` : '') +
(stats.M > 0 ? `<li>${stats.M} after a cisgender male</li>` : '') +
(statistics.F > 0 ? `<li>${statistics.F} after a cisgender female</li>` : '') +
(statistics.FX > 0 ? `<li>${statistics.FX} after a transgender female</li>` : '') +
(statistics.MX > 0 ? `<li>${statistics.MX} after a transgender male</li>` : '') +
(statistics.M > 0 ? `<li>${statistics.M} after a cisgender male</li>` : '') +
'</ul>' +
'</div>';

Expand Down