aboutsummaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorMatthew Somerville <matthew@mysociety.org>2016-02-05 21:33:52 +0000
committerMatthew Somerville <matthew@mysociety.org>2016-02-09 17:23:42 +0000
commitce25130c2a9789ad832848db1098f36065045673 (patch)
treef335dd7f639f0c6f9c43e61424df9d3a96844730 /web
parent6c718aa2e1d3fdbf9f94982a3f95ef5b5495e667 (diff)
Really stop map strategy update firing too often.
It turns out the strategy was still firing even with correctly rounded co-ordinates from getMapBounds, as there were still rounding errors introduced by the two differing ways of calculating the map bounds. We override one function to always equal the results of the other method.
Diffstat (limited to 'web')
-rw-r--r--web/js/map-OpenLayers.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 55afeabb1..6c99ee1f4 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -619,6 +619,18 @@ OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
bounds = new OpenLayers.Bounds(bounds.toArray());
}
return bounds;
+ },
+ // The above isn't enough, however, because Strategy.BBOX's getMapBounds
+ // and calculateBounds work out the bounds in different ways, the former by
+ // transforming the map's extent to the layer projection, the latter by
+ // adding or subtracting from the centre. As we have a ratio of 1, rounding
+ // errors can still occur. This override makes calculateBounds always equal
+ // getMapBounds (so no movement means no update).
+ calculateBounds: function(mapBounds) {
+ if (!mapBounds) {
+ mapBounds = this.getMapBounds();
+ }
+ this.bounds = mapBounds;
}
});