From 5f25375aabf2f13339b27978f36b79edcad53a44 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Thu, 24 May 2018 14:11:25 -0400 Subject: [PATCH 1/2] Fix having tutorials update if a text is deleted. Tutorials should rerun whenever the contents change. Some code designed to perform updates when separate code blocks were edited happened to prevent deleting text from triggering the update. --- tutorials/common/tutorials.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/common/tutorials.js b/tutorials/common/tutorials.js index 21e5e01e7b..5ee61256d4 100644 --- a/tutorials/common/tutorials.js +++ b/tutorials/common/tutorials.js @@ -192,8 +192,8 @@ function process_block_debounce(selector, debounce) { processBlockInfo.lastelem = selector; if (!debounce) { process_block(selector); + return; } - return; } processBlockInfo.timer = window.setTimeout(function () { process_block(processBlockInfo.lastelem); From c0ab444a904220001711ccc3882daea82e47af23 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Tue, 29 May 2018 11:27:29 -0400 Subject: [PATCH 2/2] Expose registries. This, or some other way, is needed to that if a feature is available in multiple renderers, so that a compound feature doesn't have to invoke a secondary renderer if the current renderer is sufficient (see the change for the annotationLayer, for instance). This also has the virtue that the geo.registries entry can be inspected to discover available features, layers, etc. --- src/annotationLayer.js | 4 ++-- src/registry.js | 11 +++++++++++ tests/cases/registry.js | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/annotationLayer.js b/src/annotationLayer.js index 8c4a9b80bb..87e29bcb8a 100644 --- a/src/annotationLayer.js +++ b/src/annotationLayer.js @@ -1012,8 +1012,8 @@ var annotationLayer = function (args) { return m_this; } if (!m_labelFeature) { - var renderer = registry.rendererForFeatures(['text']); - if (renderer !== m_this.renderer().api()) { + if (!(registry.registries.features[m_this.rendererName()] || {}).text) { + var renderer = registry.rendererForFeatures(['text']); m_labelLayer = registry.createLayer('feature', m_this.map(), {renderer: renderer}); m_this.addChild(m_labelLayer); m_labelLayer._update(); diff --git a/src/registry.js b/src/registry.js index f6183f1af1..0f664c6b3d 100644 --- a/src/registry.js +++ b/src/registry.js @@ -459,4 +459,15 @@ util.rendererForAnnotations = function (annotationList) { return util.rendererForFeatures(util.featuresForAnnotations(annotationList)); }; +/* Expose the various registries so that the can be examined to see what + * things are registered. */ +util.registries = { + annotations: annotations, + features: features, + featureCapabilities: featureCapabilities, + fileReaders: fileReaders, + layers: layers, + renderers: renderers +}; + module.exports = util; diff --git a/tests/cases/registry.js b/tests/cases/registry.js index 98a171075f..a39f06b233 100644 --- a/tests/cases/registry.js +++ b/tests/cases/registry.js @@ -25,5 +25,10 @@ describe('geo.registry', function () { expect(geo.rendererForFeatures(['point'])).toBe('d3'); restoreVGLRenderer(); }); + it('expose registries', function () { + expect(geo.registries.unknown).toBe(undefined); + expect(geo.registries.annotations).not.toBe(undefined); + expect(geo.registries.features).not.toBe(undefined); + }); }); });