If imagery becomes invalid, remove it from imagery_used

(closes #4827)
This commit is contained in:
Bryan Housel
2018-12-11 17:49:15 -05:00
parent 577e0c6503
commit 13b1a9a629
2 changed files with 18 additions and 6 deletions
+3 -3
View File
@@ -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');
+15 -3
View File
@@ -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);
}