mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Don't list non-global imagery sources at low zooms (close #7062)
Always show the currently selected background in the list (close #7061)
This commit is contained in:
@@ -212,15 +212,27 @@ export function rendererBackground(context) {
|
||||
};
|
||||
|
||||
|
||||
background.sources = function(extent) {
|
||||
background.sources = function(extent, zoom, alwaysIncludeSelected) {
|
||||
if (!data.imagery || !data.imagery.query) return []; // called before init()?
|
||||
|
||||
var matchIDs = {};
|
||||
var matchImagery = data.imagery.query.bbox(extent.rectangle(), true) || [];
|
||||
matchImagery.forEach(function(d) { matchIDs[d.id] = true; });
|
||||
|
||||
var currentSource = baseLayer.source();
|
||||
|
||||
return _backgroundSources.filter(function(source) {
|
||||
return matchIDs[source.id] || !source.polygon; // no polygon = worldwide
|
||||
// optionally always include the selected source
|
||||
if (alwaysIncludeSelected && currentSource === source) return true;
|
||||
|
||||
// always show sources with worldwide coverage
|
||||
if (!source.polygon) return true;
|
||||
|
||||
// optionally don't include non-worldwide sources at low zooms
|
||||
if (zoom && zoom < 6) return false;
|
||||
|
||||
// don't include sources outside the extent
|
||||
return matchIDs[source.id];
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ export function uiBackground(context) {
|
||||
|
||||
function drawListItems(layerList, type, change, filter) {
|
||||
var sources = context.background()
|
||||
.sources(context.map().extent())
|
||||
.sources(context.map().extent(), context.map().zoom(), true)
|
||||
.filter(filter);
|
||||
|
||||
var layerLinks = layerList.selectAll('li')
|
||||
|
||||
Reference in New Issue
Block a user