Do no try to fit data bounds if bounds are not valid

This may happen if:
- the map as some layers containing data, but set as not browsable
- any other layer is empty
This commit is contained in:
Yohan Boniface 2023-09-26 10:49:01 +02:00
parent 649f21a0d5
commit 44910f5410

View file

@ -672,11 +672,12 @@ L.U.Map.include({
this._controls.locate.start()
} else if (this.options.defaultView === 'data') {
this.onceDataLoaded(() => {
if (!this.hasData()) {
const bounds = this.getLayersBounds()
if (!this.hasData() || !bounds.isValid()) {
this._setDefaultCenter()
return
}
this.fitBounds(this.getLayersBounds())
this.fitBounds(bounds)
})
} else if (this.options.defaultView === 'latest') {
this.onceDataLoaded(() => {