Don't swith the background layer if we don't need to
This commit is contained in:
parent
9b7f8bfa47
commit
7a45477ae2
1 changed files with 13 additions and 7 deletions
|
@ -85,8 +85,15 @@ class SingleLayerSelectionButton extends Toggle {
|
||||||
options.currentBackground.setData(previousLayer.data)
|
options.currentBackground.setData(previousLayer.data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
options.currentBackground.addCallbackAndRunD(background => {
|
||||||
|
if (background.category === options.preferredType) {
|
||||||
|
previousLayer.setData(background)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
available.addCallbackAndRunD(availableLayer => {
|
|
||||||
|
available.addCallbackD(availableLayer => {
|
||||||
|
// Called whenever a better layer is available
|
||||||
|
|
||||||
if (previousLayer.data === undefined) {
|
if (previousLayer.data === undefined) {
|
||||||
// PreviousLayer is unset -> we definitively weren't using this category -> no need to switch
|
// PreviousLayer is unset -> we definitively weren't using this category -> no need to switch
|
||||||
|
@ -97,6 +104,11 @@ class SingleLayerSelectionButton extends Toggle {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Is the previous layer still valid? If so, we don't bother to switch
|
||||||
|
if(previousLayer.data.feature === null || GeoOperations.inside(locationControl.data, previousLayer.data.feature)){
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (availableLayer.category === options.preferredType) {
|
if (availableLayer.category === options.preferredType) {
|
||||||
// Allright, we can set this different layer
|
// Allright, we can set this different layer
|
||||||
options.currentBackground.setData(availableLayer)
|
options.currentBackground.setData(availableLayer)
|
||||||
|
@ -112,12 +124,6 @@ class SingleLayerSelectionButton extends Toggle {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
options.currentBackground.addCallbackAndRunD(background => {
|
|
||||||
if (background.category === options.preferredType) {
|
|
||||||
previousLayer.setData(background)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.activate = () => {
|
this.activate = () => {
|
||||||
checkPreviousLayer()
|
checkPreviousLayer()
|
||||||
if (available.data.category !== options.preferredType) {
|
if (available.data.category !== options.preferredType) {
|
||||||
|
|
Loading…
Reference in a new issue