Skip to content
Permalink
Browse files

adding santa to the map using his last known location

  • Loading branch information
colbyfayock committed Dec 10, 2019
1 parent f42c48f commit 1b636107078fce64068ce661903892c095cb4668
Showing with 53 additions and 1 deletion.
  1. +28 −0 src/assets/stylesheets/application.scss
  2. +25 −1 src/pages/index.js
@@ -21,4 +21,32 @@ body {

main {
padding: 2em 0;
}

.icon {

& > div {

display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
border-radius: 100%;
box-shadow: 0 3px 4px rgba(0,0,0,.4);
border: none;
transition: all .2s;

&:hover {
box-shadow: 0 4px 8px rgba(0,0,0,.6);
}

}

}

.icon-santa {
width: 50px;
height: 50px;
font-size: 3em;
background: white;
}
@@ -31,7 +31,31 @@ const IndexPage = () => {
} catch(e) {
throw new Error(`Failed to find Santa!: ${e}`)
}
console.log('routeJson', routeJson);

// Grab Santa's route destinations, determine which ones have presents, and figure out his last known
// location where he delivered a present

const { destinations } = routeJson;
const destinationsWithPresents = destinations.filter(({presentsDelivered}) => presentsDelivered > 0);
const lastKnownDestination = destinationsWithPresents[destinationsWithPresents.length - 1]

// Create a Leaflet LatLng instance using that location

const santaLocation = new L.LatLng( lastKnownDestination.location.lat, lastKnownDestination.location.lng );

// Create a Leaflet Market instance using Santa's LatLng location

const santaMarker = L.marker( santaLocation, {
icon: L.divIcon({
className: 'icon',
html: `<div class="icon-santa">🎅</div>`,
iconSize: 50
})
});

// Add Santa to the map!

santaMarker.addTo(leafletElement);
}

const mapSettings = {

0 comments on commit 1b63610

Please sign in to comment.
You can’t perform that action at this time.