From 61b209e817f8242568c4926e8952468cd3468680 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Thu, 26 Sep 2013 23:01:35 +0100 Subject: [PATCH] fix handling of too many portals. also make it dependant on visible portals only --- plugins/portal-names.user.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/plugins/portal-names.user.js b/plugins/portal-names.user.js index ddf06b6b..24ef4f57 100644 --- a/plugins/portal-names.user.js +++ b/plugins/portal-names.user.js @@ -21,6 +21,7 @@ // use own namespace for plugin window.plugin.portalNames = function() {}; +window.plugin.portalNames.MAX_PORTALS = 250; window.plugin.portalNames.NAME_WIDTH = 80; window.plugin.portalNames.NAME_HEIGHT = 23; @@ -82,13 +83,6 @@ window.plugin.portalNames.addLabel = function(guid, latLng) { window.plugin.portalNames.updatePortalLabels = function() { - if (Object.keys(window.portals).length > 1000) { - // too manuy portals to handle quickly - clear all - window.plugin.portalNames.labelLayerGroup.clear(); - window.plugin.portalNames.labelLayers = {}; - return; - } - var portalPoints = {}; for (var guid in window.portals) { @@ -99,6 +93,14 @@ window.plugin.portalNames.updatePortalLabels = function() { } } + if (Object.keys(portalPoints).length > window.plugin.portalNames.MAX_PORTALS) { + // too manuy VISIBLE portals to handle quickly - clear all + window.plugin.portalNames.labelLayerGroup.clearLayers(); + window.plugin.portalNames.labelLayers = {}; + return; + } + + var coveredPortals = {}; for (var guid in portalPoints) {