Skip to content

Commit 7a766aa

Browse files
committed
feat: added country map to the website
1 parent 61be75d commit 7a766aa

File tree

6 files changed

+113
-3
lines changed

6 files changed

+113
-3
lines changed

personal/package-lock.json

Lines changed: 18 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

personal/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "aaronczichon.de",
33
"type": "module",
4-
"version": "1.0.0",
4+
"version": "1.0.1",
55
"description": "Personal website of Aaron Czichon",
66
"scripts": {
77
"dev": "astro dev",
@@ -28,6 +28,7 @@
2828
"typescript": "^5.3.3"
2929
},
3030
"devDependencies": {
31+
"@types/mapbox-gl": "^3.1.0",
3132
"prettier": "^3.2.5",
3233
"prettier-plugin-astro": "^0.13.0"
3334
}

personal/src/components/Nav.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ import { Image } from "astro:assets";
3131
class={currentPath.indexOf("cv") > -1 ? "active" : ""}>CV</a
3232
> -->
3333
<a href="/cv/" class={currentPath.indexOf("cv") > -1 ? "active" : ""}>CV</a>
34+
<a
35+
href="/visited-countries/"
36+
class={currentPath.indexOf("visited-countries") > -1 ? "active" : ""}
37+
>Visited Countries</a
38+
>
3439
<!-- <a
3540
href="/pengiun"
3641
class={currentPath.indexOf("pengiun") > -1 ? "active" : ""}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useState, useEffect } from 'preact/hooks';
2+
3+
import BasicMap from './BasicMap';
4+
import { addMapLayer } from './map.func';
5+
6+
export default function CountryDynamicMap({zoom, center}) {
7+
const [map, setMap] = useState(null);
8+
useEffect(() => {
9+
// Add route to map
10+
if (map) {
11+
map.on('load', () => {
12+
addMapLayer(map);
13+
});
14+
}
15+
}, [map]);
16+
17+
useEffect(() => {
18+
if (map) {
19+
map.setCenter(center);
20+
}
21+
})
22+
23+
return (
24+
<BasicMap zoom={zoom} setMap={setMap} />
25+
);
26+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import * as mapboxgl from 'mapbox-gl';
2+
3+
export const addMapLayer = (map: mapboxgl.Map) => {
4+
map.addSource('countries', {
5+
type: 'vector',
6+
url: 'mapbox://mapbox.country-boundaries-v1'
7+
});
8+
9+
map.addLayer(
10+
{
11+
id: 'country-boundaries',
12+
source: 'countries',
13+
'source-layer': 'country_boundaries',
14+
type: 'fill',
15+
paint: {
16+
'fill-color': '#19bf32',
17+
'fill-opacity': 0.7,
18+
},
19+
},
20+
'country-label'
21+
);
22+
23+
// ISO List: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
24+
map.setFilter('country-boundaries', [
25+
"in",
26+
"iso_3166_1_alpha_3",
27+
'ITA',
28+
'CAN',
29+
'DEU',
30+
'ESP',
31+
'SVK',
32+
'SVN',
33+
'CZE',
34+
'HRV',
35+
'BEL',
36+
'NOR',
37+
'AUT',
38+
'LTU',
39+
'FIN',
40+
'EST',
41+
'USA',
42+
'CHE',
43+
'FRA'
44+
]);
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
import Layout from "../layouts/Layout.astro";
3+
import CountryMap from "../components/dynamic/CountryMap";
4+
---
5+
6+
<Layout title="Aaron Czichon - Visited Countries">
7+
<main class="container">
8+
<h1>Visited Countries</h1>
9+
<p>
10+
I've already visited a bunch of countries in my life. I love to keep track
11+
of such things.
12+
</p>
13+
</main>
14+
15+
<!-- Map Component here -->
16+
<CountryMap client:visible zoom="3" center={[10.451526, 51.165691]} />
17+
</Layout>

0 commit comments

Comments
 (0)