aboutsummaryrefslogtreecommitdiffstats
path: root/web/js/map-OpenLayers.js
diff options
context:
space:
mode:
authorDave Arter <davea@mysociety.org>2020-01-08 17:11:05 +0000
committerDave Arter <davea@mysociety.org>2020-01-09 15:50:31 +0000
commit757cacc10f51a9c54d02c392e9e39e23202dac72 (patch)
tree2cf4ba16adaf896462072b5dffe55702dd20a0dc /web/js/map-OpenLayers.js
parent0cbcf9e9a1153f3463abc01268891658b2853e12 (diff)
Reduce duplicate Permalink.updateLink calls when zooming map
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r--web/js/map-OpenLayers.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js
index 4af5e61d4..a10e13378 100644
--- a/web/js/map-OpenLayers.js
+++ b/web/js/map-OpenLayers.js
@@ -1108,6 +1108,24 @@ OpenLayers.Control.PermalinkFMS = OpenLayers.Class(OpenLayers.Control.Permalink,
updateLink: function() {
this._updateLink(0);
},
+ draw: function() {
+ OpenLayers.Control.Permalink.prototype.draw.apply(this, arguments);
+
+ // fms.com has so many layers now that zooming events were causing
+ // enough quick-fire history.replaceState calls (in updateLink)
+ // that iOS Safari was raising "SecurityError: Attempt to use
+ // history.replaceState() more than 100 times per 30 seconds" errors,
+ // as well as being throttled on Chrome on Android. Zooming in causes
+ // lots of layers to come into range simultaneously, and each was
+ // triggering the 'changelayer' event. In our use we don't include the
+ // layers state string in the permalink URL (see `delete params.layers`
+ // above), so there's no need to listen to those events.
+ this.map.events.un({
+ 'changelayer': this.updateLink,
+ 'changebaselayer': this.updateLink,
+ scope: this
+ });
+ },
CLASS_NAME: "OpenLayers.Control.PermalinkFMS"
});