Merge pull request #9076 from renancleyson-dev/fix-imagery-unselected

Fix iD using invalid user selected imagery
This commit is contained in:
Martin Raifer
2022-07-15 19:04:23 +02:00
committed by GitHub
2 changed files with 14 additions and 8 deletions
+3
View File
@@ -56,6 +56,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Fix localizable labels in multiCombo fields ("chips") being rendered multiple times ([#9169])
* Fix missing styling when rendering of proposed footway/cycleway/path bridges ([#9172], thanks [@k-yle])
* Fix some boundary lines (and preset) not hidden by the map features filter ([#9171], thanks [@k-yle])
* Fix iD using invalid user selected imagery ([#8732], thanks [@renancleyson-dev])
#### :rocket: Presets
* Disable taginfo suggestions for the `via` field ([#9140], thanks [@k-yle])
* Treat `surface=chipseal` as a paved surface ([#9139], thanks [@k-yle])
@@ -68,6 +69,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[#8419]: https://github.com/openstreetmap/iD/issues/8419
[#8732]: https://github.com/openstreetmap/iD/issues/8732
[#8881]: https://github.com/openstreetmap/iD/issues/8881
[#8975]: https://github.com/openstreetmap/iD/pull/8975
[#9018]: https://github.com/openstreetmap/iD/issues/9018
@@ -87,6 +89,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[@JackNUMBER]: https://github.com/JackNUMBER
[@aaditya0000]: https://github.com/aaditya0000
[@paulklie]: https://github.com/paulklie
[@renancleyson-dev]: https://github.com/renancleyson-dev
# 2.21.1
+11 -8
View File
@@ -454,29 +454,32 @@ export function rendererBackground(context) {
}
const hash = utilStringQs(window.location.hash);
const requested = hash.background || hash.layer;
const requestedBackground = hash.background || hash.layer;
const lastUsedBackground = prefs('background-last-used');
let extent = parseMapParams(hash.map);
return _loadPromise = ensureImageryIndex()
.then(imageryIndex => {
const first = imageryIndex.backgrounds.length && imageryIndex.backgrounds[0];
const validBackgrounds = background.sources(extent).filter(d => d.id !== 'none' && d.id !== 'custom');
const first = validBackgrounds.length && validBackgrounds[0];
const isLastUsedValid = !!validBackgrounds.find(d => d.id && d.id === lastUsedBackground);
let best;
if (!requested && extent) {
best = background.sources(extent).find(s => s.best());
if (!requestedBackground && extent) {
best = validBackgrounds.find(s => s.best());
}
// Decide which background layer to display
if (requested && requested.indexOf('custom:') === 0) {
const template = requested.replace(/^custom:/, '');
if (requestedBackground && requestedBackground.indexOf('custom:') === 0) {
const template = requestedBackground.replace(/^custom:/, '');
const custom = background.findSource('custom');
background.baseLayerSource(custom.template(template));
prefs('background-custom-template', template);
} else {
background.baseLayerSource(
background.findSource(requested) ||
background.findSource(requestedBackground) ||
best ||
background.findSource(prefs('background-last-used')) ||
isLastUsedValid && background.findSource(lastUsedBackground) ||
background.findSource('Bing') ||
first ||
background.findSource('none')