Skip to content

Commit

Permalink
added marker colors on basis of the days
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-vaghasiya committed Aug 5, 2023
1 parent 2f2fe6d commit 80878d2
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions maps.html
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@
events[i];
if (i == 0) map.setCenter(geo);

const day = new Date(start_time).getDay();

const marker = new google.maps.Marker({
position: geo,
map,
Expand All @@ -156,6 +158,7 @@
fontWeight: 'bold',
fontSize: '16px',
text: title,
color: getColorFromDayOfWeek(day),
},
});
const info = `${title}\n\n\n${description}`;
Expand Down Expand Up @@ -188,6 +191,50 @@ <h5>${location}</h5>
<p>${description}</p>`;
}

function getColorFromDayOfWeek(day) {
switch (day) {
case 0:
return 'red';
case 1:
return 'blue';
case 2:
return 'green';
case 3:
return 'yellow';
case 4:
return 'orange';
case 5:
return 'purple';
case 6:
return 'pink';
}
}
// show day and color on left side of the map
function showDayColor() {
const days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const div = document.createElement('div');
div.style.position = 'fixed';
div.style.top = '50%';
div.style.left = '0';
div.style.transform = 'translateY(-50%)';
div.style.padding = '1em';
div.style.backgroundColor = 'white';
div.style.borderRadius = '0 5px 5px 0';
div.style.boxShadow = '0 0 5px rgba(0,0,0,0.5)';
div.style.zIndex = '1000';
for (let i = 0; i < days.length; i++) {
const day = days[i];
const span = document.createElement('span');
span.style.display = 'block';
span.style.marginBottom = '0.5em';
span.style.color = getColorFromDayOfWeek(i);
span.innerHTML = `${day}`;
div.appendChild(span);
}
document.body.appendChild(div);
}
showDayColor();

function clearMarkers() {
for (let i = 0; i < markers.length; i++) {
const marker = markers[i];
Expand Down

0 comments on commit 80878d2

Please sign in to comment.