From 757cacc10f51a9c54d02c392e9e39e23202dac72 Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Wed, 8 Jan 2020 17:11:05 +0000 Subject: Reduce duplicate Permalink.updateLink calls when zooming map --- web/js/map-OpenLayers.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'web/js') 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" }); -- cgit v1.2.3