Skip to content

Commit

Permalink
Maki icons, first attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
art-solopov committed Nov 8, 2023
1 parent 060142d commit 4ee593d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 15 deletions.
12 changes: 12 additions & 0 deletions assets/js/components/map/icons/amusement-park.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/components/map/icons/castle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/js/components/map/icons/grocery.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/js/components/map/icons/home.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions assets/js/components/map/icons/museum.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/js/components/map/icons/rail-light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/js/components/map/icons/restaurant.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/js/components/map/icons/triangle-stroked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 17 additions & 13 deletions assets/js/components/map/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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}`
Expand All @@ -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 = `
<svg class=${styles.markerBody}><use xlink:href="${iconsUrl}#geo-alt-fill"></svg>
<svg class=${styles.markerIcon}><use xlink:href="${iconsUrl}#${icon}-fill"></svg>
`
import(`../icons/${icon}.svg`).then(i => {
el.innerHTML = `
<svg class=${styles.markerBody}><use xlink:href="${iconsUrl}#geo-alt-fill"></svg>
<img class=${styles.markerIcon} src=${i.default}></img>
`
})


new mapboxgl.Marker({
anchor: 'bottom',
Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/map/lib/marker-styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

.marker {
$size: 3.5rem;
$icon-size: 0.3 * $size;
$icon-size: 0.5 * $size;

height: $size;
width: $size;
Expand All @@ -21,7 +21,7 @@
width: $icon-size;
position: absolute;

top: 0.22 * $size;
top: 0.15 * $size;
left: 0.5 * ($size - $icon-size);
}

Expand Down

0 comments on commit 4ee593d

Please sign in to comment.