-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from aaronczichon/feature/visited-countries
feat: added country map to the website
- Loading branch information
Showing
12 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useState, useEffect } from 'preact/hooks'; | ||
|
||
import BasicMap from './BasicMap'; | ||
import { addMapLayer } from './map.func'; | ||
|
||
export default function CountryDynamicMap({zoom, center}) { | ||
const [map, setMap] = useState(null); | ||
useEffect(() => { | ||
// Add route to map | ||
if (map) { | ||
map.on('load', () => { | ||
addMapLayer(map); | ||
}); | ||
} | ||
}, [map]); | ||
|
||
useEffect(() => { | ||
if (map) { | ||
map.setCenter(center); | ||
} | ||
}) | ||
|
||
return ( | ||
<BasicMap zoom={zoom} setMap={setMap} /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import * as mapboxgl from 'mapbox-gl'; | ||
|
||
export const addMapLayer = (map: mapboxgl.Map) => { | ||
map.addSource('countries', { | ||
type: 'vector', | ||
url: 'mapbox://mapbox.country-boundaries-v1' | ||
}); | ||
|
||
map.addLayer( | ||
{ | ||
id: 'country-boundaries', | ||
source: 'countries', | ||
'source-layer': 'country_boundaries', | ||
type: 'fill', | ||
paint: { | ||
'fill-color': '#19bf32', | ||
'fill-opacity': 0.7, | ||
}, | ||
}, | ||
'country-label' | ||
); | ||
|
||
// ISO List: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3 | ||
map.setFilter('country-boundaries', [ | ||
"in", | ||
"iso_3166_1_alpha_3", | ||
'ITA', | ||
'CAN', | ||
'DEU', | ||
'ESP', | ||
'SVK', | ||
'SVN', | ||
'CZE', | ||
'HRV', | ||
'BEL', | ||
'NOR', | ||
'AUT', | ||
'LTU', | ||
'FIN', | ||
'EST', | ||
'USA', | ||
'CHE', | ||
'FRA' | ||
]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
import Layout from "../layouts/Layout.astro"; | ||
import CountryMap from "../components/dynamic/CountryMap"; | ||
--- | ||
|
||
<Layout title="Aaron Czichon - Visited Countries"> | ||
<main class="container"> | ||
<h1>Visited Countries</h1> | ||
<p> | ||
I've already visited a bunch of countries in my life. I love to keep track | ||
of such things. | ||
</p> | ||
</main> | ||
|
||
<!-- Map Component here --> | ||
<CountryMap client:visible zoom="3" center={[10.451526, 51.165691]} /> | ||
</Layout> |