aboutsummaryrefslogtreecommitdiffstats
path: root/web/js
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 14:50:45 +0000
commit8f7a1bdc5e9deb904f0847fffd4a01995272449d (patch)
treea442665aa83ae6146cb862111f403d6c92bae748 /web/js
parentb71d042e933ba03e3c737d8630d4e3d4ca3eb9d1 (diff)
Stop map strategy update firing too often.
Diffstat (limited to 'web/js')
-rw-r--r--web/js/map-OpenLayers.js17
1 files changed, 16 insertions, 1 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 2d119e8d0..55afeabb1 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -276,7 +276,7 @@ function fixmystreet_onload() {
styleMap: pin_layer_style_map
};
if (fixmystreet.page == 'around') {
- fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.BBOX({ ratio: 1 });
+ fixmystreet.bbox_strategy = fixmystreet.bbox_strategy || new OpenLayers.Strategy.FixMyStreet();
pin_layer_options.strategies = [ fixmystreet.bbox_strategy ];
pin_layer_options.protocol = new OpenLayers.Protocol.FixMyStreet({
url: '/ajax',
@@ -607,6 +607,21 @@ OpenLayers.Control.PermalinkFMSz = OpenLayers.Class(OpenLayers.Control.Permalink
}
});
+OpenLayers.Strategy.FixMyStreet = OpenLayers.Class(OpenLayers.Strategy.BBOX, {
+ ratio: 1,
+ // The transform in Strategy.BBOX's getMapBounds could mean you end up with
+ // co-ordinates too precise, which could then cause the Strategy to think
+ // it needs to update when it doesn't. So create a new bounds out of the
+ // provided one to make sure it's passed through toFloat().
+ getMapBounds: function() {
+ var bounds = OpenLayers.Strategy.BBOX.prototype.getMapBounds.apply(this);
+ if (bounds) {
+ bounds = new OpenLayers.Bounds(bounds.toArray());
+ }
+ return bounds;
+ }
+});
+
/* Pan data request handler */
// This class is used to get a JSON object from /ajax that contains
// pins for the map and HTML for the sidebar. It does a fetch whenever the map