diff --git a/README.md b/README.md index 77ee91f..c3edc7e 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,8 @@ somewhere in the `body`. In order to turn on or off default checkboxes, open up `map.js`, CTRL+F 'DEFAULT_CHECKS', and change a value to `false` to turn it off by default and `true` to turn it on by default. +In order to change the default view (currently shipped with weekly data as default) to the past month, week, or day, open `map.js`, CTRL+F 'DEFAULT_VIEW', and read the documentation. You can change the value to "month", "week", or "day"; anything else will default to weekly data. + ## Getting started: 1. Fork the project 2. Add your name to `contributors.md` diff --git a/map.js b/map.js index d8b3e48..89fb9c0 100644 --- a/map.js +++ b/map.js @@ -9,7 +9,8 @@ WPRDC_QUERY_SUFFIX, PITT_LAUNDRY, PITT_LABS, - DEFAULT_CHECKS; + DEFAULT_CHECKS, + DEFAULT_VIEW; // await those values window.addEventListener("dataready", function handler(event) { @@ -28,6 +29,12 @@ // true = turned on by default; false = turned off by default DEFAULT_CHECKS = { "library": true, "arrest": true, "police": true, "code violation": true, "non-traffic violation": true, "311": true, "labs": true, "laundry": true }; + // choose the default data shown in the map; can hold 1 of 3 strings: + // "month" = show data from the previous 30 days + // "week" = show data from the previous 7 days + // "day" = show data from the previous day + DEFAULT_VIEW = "week"; + // wait for these values before fetching dependant data fetchAllData(); @@ -383,7 +390,6 @@ record.filtered = true; if (filter.checked == true) { - record.pin.addTo(map); record.filtered = false; } @@ -652,8 +658,19 @@ retryDiv.appendChild(retryButton); }); }).then(() => { - //display past week map as default - displayPastWeek(); + switch (DEFAULT_VIEW) { + case "month": + displayPastMonth(); + break; + case "week": + displayPastWeek(); + break; + case "day": + displayPastDay(); + break; + default: + displayPastWeek(); + } displayMapMode(); generateDataTable(); });