Default view datalayer code refacto
This commit is contained in:
parent
29ab98ede3
commit
f053e06686
1 changed files with 13 additions and 9 deletions
|
@ -694,10 +694,17 @@ L.U.Map.include({
|
||||||
this._setDefaultCenter()
|
this._setDefaultCenter()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const datalayer = this.defaultViewDataLayer(),
|
const datalayer = this.firstVisibleDatalayer()
|
||||||
feature = datalayer ? datalayer.getFeatureByIndex(-1) : null
|
let feature
|
||||||
if (feature) feature.zoomTo()
|
if (datalayer) {
|
||||||
else this._setDefaultCenter()
|
const feature = datalayer.getFeatureByIndex(-1)
|
||||||
|
if (feature) {
|
||||||
|
feature.zoomTo()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Fallback, no datalayer or no feature found
|
||||||
|
this._setDefaultCenter()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this._setDefaultCenter()
|
this._setDefaultCenter()
|
||||||
|
@ -1225,13 +1232,10 @@ L.U.Map.include({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultViewDataLayer: function () {
|
firstVisibleDatalayer: function () {
|
||||||
let datalayer, fallback
|
return this.findDataLayer((datalayer) => {
|
||||||
datalayer = this.findDataLayer((datalayer) => {
|
|
||||||
fallback = datalayer
|
|
||||||
if (datalayer.isVisible()) return true
|
if (datalayer.isVisible()) return true
|
||||||
})
|
})
|
||||||
return datalayer || fallback
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO: allow to control the default datalayer
|
// TODO: allow to control the default datalayer
|
||||||
|
|
Loading…
Reference in a new issue