Commit 855488d2 authored by midgard's avatar midgard

Fix holiday season and improve icon selection

parent 9e72a5dc
$(document).ready(function() { $(document).ready(function() {
/* change image path */
L.Icon.Default.imagePath = "img/"; L.Icon.Default.imagePath = "img/";
var popuptemplate = Handlebars.compile($("#popup-template").html()); var popuptemplate = Handlebars.compile($("#popup-template").html());
var RedIcon = L.Icon.Default.extend({ var RedIcon = L.Icon.Default.extend({
options: { options: {
iconUrl: "red-marker.png" iconUrl: "red-marker.png"
...@@ -13,11 +13,15 @@ $(document).ready(function() { ...@@ -13,11 +13,15 @@ $(document).ready(function() {
iconUrl: "christmas-marker.png" iconUrl: "christmas-marker.png"
} }
}); });
var blueIcon = new L.Icon.Default();
var redIcon = new RedIcon(); var redIcon = new RedIcon();
var BlueIcon = L.Icon.Default.extend({});
var blueIcon = new BlueIcon();
var christmasIcon = new ChristmasIcon(); var christmasIcon = new ChristmasIcon();
var christmasHoliday = Date.now() < new Date("2016-01-04").getTime();
var now = new Date();
var christmasSeason =
now.getTime() > new Date(now.getFullYear() + "-12-20").getTime() ||
now.getTime() < new Date(now.getFullYear() + "-01-04").getTime();
function onEachFeature(feature, layer) { function onEachFeature(feature, layer) {
if (feature.properties) { if (feature.properties) {
...@@ -28,16 +32,15 @@ $(document).ready(function() { ...@@ -28,16 +32,15 @@ $(document).ready(function() {
} }
function pointToLayer(feature, latlng) { function pointToLayer(feature, latlng) {
var marker = new HoverMarker(latlng, { icon: redIcon, riseOnHover: true}); var icon = redIcon;
if (feature.properties) { if (feature.properties) {
if (feature.properties.holidays && christmasHoliday) { if (feature.properties.holidays && christmasSeason) {
var marker = new HoverMarker(latlng, { icon: christmasIcon, riseOnHover: true}); icon = christmasIcon;
} } else if (!feature.properties.hours.saturday && !feature.properties.hours.sunday) {
if (!feature.properties.hours.saturday && !feature.properties.hours.sunday) { icon = blueIcon;
var marker = new HoverMarker(latlng, { icon: blueIcon, riseOnHover: true});
} }
} }
return marker; return new HoverMarker(latlng, { icon: icon, riseOnHover: true});
} }
var map = L.map("map").setView([50.702, 4.335], 9); var map = L.map("map").setView([50.702, 4.335], 9);
...@@ -150,7 +153,7 @@ $(document).ready(function() { ...@@ -150,7 +153,7 @@ $(document).ready(function() {
position: "bottomleft" position: "bottomleft"
}).addTo(map); }).addTo(map);
var legend = new SimpleControl("#legend-template", christmasHoliday ? "holiday-legend" : "legend", { var legend = new SimpleControl("#legend-template", christmasSeason ? "holiday-legend" : "legend", {
position: "bottomright" position: "bottomright"
}).addTo(map); }).addTo(map);
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment