diff --git a/modules/core/history.js b/modules/core/history.js index 57e3a22606..a07474041d 100644 --- a/modules/core/history.js +++ b/modules/core/history.js @@ -32,10 +32,10 @@ import { export function coreHistory(context) { - var imageryUsed = ['Bing']; var dispatch = d3_dispatch('change', 'undone', 'redone'); var lock = utilSessionMutex('lock'); var duration = 150; + var _imageryUsed = []; var _checkpoints = {}; var _stack; var _index; @@ -62,7 +62,7 @@ export function coreHistory(context) { return { graph: graph, annotation: annotation, - imageryUsed: imageryUsed + imageryUsed: _imageryUsed }; } @@ -294,7 +294,7 @@ export function coreHistory(context) { imageryUsed: function(sources) { if (sources) { - imageryUsed = sources; + _imageryUsed = sources; return history; } else { var arr = _map(_stack.slice(1, _index + 1), 'imageryUsed'); diff --git a/modules/renderer/background.js b/modules/renderer/background.js index 5136063843..e5491f096f 100644 --- a/modules/renderer/background.js +++ b/modules/renderer/background.js @@ -19,6 +19,7 @@ export function rendererBackground(context) { var dispatch = d3_dispatch('change'); var detected = utilDetect(); var baseLayer = rendererTileLayer(context).projection(context.projection); + var _isValid = true; var _overlayLayers = []; var _backgroundSources = []; var _brightness = 1; @@ -38,6 +39,17 @@ export function rendererBackground(context) { } } + // Is the imagery valid here? - #4827 + var sources = background.sources(context.map().extent()); + var wasValid = _isValid; + _isValid = !!sources + .filter(function(d) { return d === baseLayer.source(); }).length; + + if (wasValid !== _isValid) { // change in valid status + background.updateImagery(); + } + + var baseFilter = ''; if (detected.cssfilters) { if (_brightness !== 1) { @@ -123,9 +135,9 @@ export function rendererBackground(context) { background.updateImagery = function() { - if (context.inIntro()) return; + var b = baseLayer.source(); + if (context.inIntro() || !b) return; - var b = background.baseLayerSource(); var o = _overlayLayers .filter(function (d) { return !d.source().isLocatorOverlay() && !d.source().isHidden(); }) .map(function (d) { return d.source().id; }) @@ -167,7 +179,7 @@ export function rendererBackground(context) { var imageryUsed = []; var current = b.imageryUsed(); - if (current) { + if (current && _isValid) { imageryUsed.push(current); }