aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/cobrands/fixmystreet/density-map.js (renamed from web/cobrands/bromley/js.js)16
-rw-r--r--web/js/map-OpenLayers.js17
-rw-r--r--web/vendor/HeatmapLayer.js (renamed from web/cobrands/bromley/HeatmapLayer.js)0
3 files changed, 27 insertions, 6 deletions
diff --git a/web/cobrands/bromley/js.js b/web/cobrands/fixmystreet/density-map.js
index 8ff314189..9febf66d7 100644
--- a/web/cobrands/bromley/js.js
+++ b/web/cobrands/fixmystreet/density-map.js
@@ -19,12 +19,15 @@ if (window.Heatmap) {
fixmystreet.protocol_params.wards = 'wards';
fixmystreet.protocol_params.start_date = 'start_date';
fixmystreet.protocol_params.end_date = 'end_date';
+fixmystreet.protocol_params.body = 'body';
$(function(){
if (!window.Heatmap) {
return;
}
+ var heatmap_on = $('input[name=heatmap]:checked').val() === 'Yes';
+
var heat_layer = new Heatmap.Layer("Heatmap");
heat_layer.setOpacity(0.7);
heat_layer.setVisibility(false);
@@ -59,17 +62,22 @@ $(function(){
fixmystreet.markers.setVisibility(true);
});
+ if (heatmap_on) {
+ fixmystreet.markers.setVisibility(false);
+ heat_layer.setVisibility(true);
+ }
+
$('#sort').closest('.report-list-filters').hide();
- $("#wards, #start_date, #end_date").on("change.filters", function() {
+ $("#wards, #start_date, #end_date").on("change.filters", debounce(function() {
// If the category or status has changed we need to re-fetch map markers
fixmystreet.markers.events.triggerEvent("refresh", {force: true});
- });
- $("#filter_categories, #statuses").on("change.filters", function() {
+ }, 1000));
+ $("#filter_categories, #statuses").on("change.filters", debounce(function() {
if (!fixmystreet.markers.getVisibility()) {
// If not visible, still want to trigger change for heatmap
fixmystreet.markers.events.triggerEvent("refresh", {force: true});
}
- });
+ }, 1000));
});
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 1588bda2e..eb62904b0 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -10,6 +10,19 @@ if (!Object.keys) {
};
}
+function debounce(fn, delay) {
+ var timeout;
+ return function() {
+ var that = this, args = arguments;
+ var debounced = function() {
+ timeout = null;
+ fn.apply(that, args);
+ };
+ clearTimeout(timeout);
+ timeout = setTimeout(debounced, delay);
+ };
+}
+
var fixmystreet = fixmystreet || {};
fixmystreet.utils = fixmystreet.utils || {};
@@ -428,10 +441,10 @@ $.extend(fixmystreet.utils, {
}
}
- function categories_or_status_changed() {
+ var categories_or_status_changed = debounce(function() {
// If the category or status has changed we need to re-fetch map markers
fixmystreet.markers.refresh({force: true});
- }
+ }, 1000);
function replace_query_parameter(qs, id, key) {
var value,
diff --git a/web/cobrands/bromley/HeatmapLayer.js b/web/vendor/HeatmapLayer.js
index 93f3e84b2..93f3e84b2 100644
--- a/web/cobrands/bromley/HeatmapLayer.js
+++ b/web/vendor/HeatmapLayer.js