From 4ee593d1ebd1570d20801a8aff3cd5e60002cf66 Mon Sep 17 00:00:00 2001 From: Artemiy Solopov Date: Wed, 8 Nov 2023 21:20:51 +0200 Subject: [PATCH] Maki icons, first attempt --- .../components/map/icons/amusement-park.svg | 12 ++++++++ assets/js/components/map/icons/castle.svg | 5 ++++ assets/js/components/map/icons/grocery.svg | 1 + assets/js/components/map/icons/home.svg | 5 ++++ assets/js/components/map/icons/museum.svg | 2 ++ assets/js/components/map/icons/rail-light.svg | 4 +++ assets/js/components/map/icons/restaurant.svg | 4 +++ .../components/map/icons/triangle-stroked.svg | 4 +++ assets/js/components/map/lib/index.js | 30 +++++++++++-------- .../map/lib/marker-styles.module.scss | 4 +-- 10 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 assets/js/components/map/icons/amusement-park.svg create mode 100644 assets/js/components/map/icons/castle.svg create mode 100644 assets/js/components/map/icons/grocery.svg create mode 100644 assets/js/components/map/icons/home.svg create mode 100644 assets/js/components/map/icons/museum.svg create mode 100644 assets/js/components/map/icons/rail-light.svg create mode 100644 assets/js/components/map/icons/restaurant.svg create mode 100644 assets/js/components/map/icons/triangle-stroked.svg diff --git a/assets/js/components/map/icons/amusement-park.svg b/assets/js/components/map/icons/amusement-park.svg new file mode 100644 index 0000000..ec1dbcf --- /dev/null +++ b/assets/js/components/map/icons/amusement-park.svg @@ -0,0 +1,12 @@ +amusement-park.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/castle.svg b/assets/js/components/map/icons/castle.svg new file mode 100644 index 0000000..dd96272 --- /dev/null +++ b/assets/js/components/map/icons/castle.svg @@ -0,0 +1,5 @@ +castle.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/grocery.svg b/assets/js/components/map/icons/grocery.svg new file mode 100644 index 0000000..432a504 --- /dev/null +++ b/assets/js/components/map/icons/grocery.svg @@ -0,0 +1 @@ +grocery.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/home.svg b/assets/js/components/map/icons/home.svg new file mode 100644 index 0000000..c47a082 --- /dev/null +++ b/assets/js/components/map/icons/home.svg @@ -0,0 +1,5 @@ +home.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/museum.svg b/assets/js/components/map/icons/museum.svg new file mode 100644 index 0000000..e80d17c --- /dev/null +++ b/assets/js/components/map/icons/museum.svg @@ -0,0 +1,2 @@ +museum.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/rail-light.svg b/assets/js/components/map/icons/rail-light.svg new file mode 100644 index 0000000..361a8af --- /dev/null +++ b/assets/js/components/map/icons/rail-light.svg @@ -0,0 +1,4 @@ +rail-light.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/restaurant.svg b/assets/js/components/map/icons/restaurant.svg new file mode 100644 index 0000000..635aa45 --- /dev/null +++ b/assets/js/components/map/icons/restaurant.svg @@ -0,0 +1,4 @@ +restaurant.svg \ No newline at end of file diff --git a/assets/js/components/map/icons/triangle-stroked.svg b/assets/js/components/map/icons/triangle-stroked.svg new file mode 100644 index 0000000..74e9cc4 --- /dev/null +++ b/assets/js/components/map/icons/triangle-stroked.svg @@ -0,0 +1,4 @@ +triangle-stroked.svg \ No newline at end of file diff --git a/assets/js/components/map/lib/index.js b/assets/js/components/map/lib/index.js index 44d1f88..3813b94 100644 --- a/assets/js/components/map/lib/index.js +++ b/assets/js/components/map/lib/index.js @@ -12,16 +12,15 @@ const FIT_BOUND_OPTIONS = { maxZoom: FOCUS_ZOOM } -// TODO: maybe inject from backend const ICONS = { - museum: 'easel', - sight: 'star', - transport: 'train-front', - accomodation: 'house', - food: 'cup-hot', - entertainment: 'dpad', - shop: 'basket3', - other: 'pentagon' + museum: 'museum', + sight: 'castle', + transport: 'rail-light', + accomodation: 'home', + food: 'restaurant', + entertainment: 'amusement-park', + shop: 'grocery', + other: 'triangle-stroked' } export async function mapInit(apiKey, options) { @@ -83,6 +82,8 @@ function loadMap(options) { } function addPointsMarkers(map, points, colors) { + console.log(ic) + for (let point of points) { const el = document.createElement('div') el.className = `${styles.marker} is-${point.category}` @@ -92,10 +93,13 @@ function addPointsMarkers(map, points, colors) { // el.style.setProperty('--marker-body-color', colors[point.category]) const icon = ICONS[point.category] - el.innerHTML = ` - - - ` + import(`../icons/${icon}.svg`).then(i => { + el.innerHTML = ` + + + ` + }) + new mapboxgl.Marker({ anchor: 'bottom', diff --git a/assets/js/components/map/lib/marker-styles.module.scss b/assets/js/components/map/lib/marker-styles.module.scss index 40f750b..88d979b 100644 --- a/assets/js/components/map/lib/marker-styles.module.scss +++ b/assets/js/components/map/lib/marker-styles.module.scss @@ -2,7 +2,7 @@ .marker { $size: 3.5rem; - $icon-size: 0.3 * $size; + $icon-size: 0.5 * $size; height: $size; width: $size; @@ -21,7 +21,7 @@ width: $icon-size; position: absolute; - top: 0.22 * $size; + top: 0.15 * $size; left: 0.5 * ($size - $icon-size); }