Merge pull request #1347 from umap-project/load-invalid-bounds

Do no try to fit data bounds if bounds are not valid
This commit is contained in:
Yohan Boniface 2023-09-26 15:37:52 +02:00 committed by GitHub
commit 6008146110
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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