fix(#2391): split zoomTo to accept bounds

Since de921660c9 (diff-4a01a166046bdf7e4ea7d41d97cd82a57c82f63d10d1697f76e6fe22bfa769ebR954) we were calling it with bounds but also with the click event sometimes.
This commit is contained in:
David Larlet 2024-12-20 09:25:25 -05:00
parent 17e6cf7500
commit 7cb6c0c45f
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD
2 changed files with 7 additions and 3 deletions

View file

@ -950,9 +950,13 @@ export class DataLayer extends ServerStored {
else this.hide() else this.hide()
} }
zoomTo(bounds) { zoomTo() {
if (!this.isVisible()) return if (!this.isVisible()) return
bounds = bounds || this.layer.getBounds() const bounds = this.layer.getBounds()
this.zoomToBounds(bounds)
}
zoomToBounds(bounds) {
if (bounds.isValid()) { if (bounds.isValid()) {
const options = { maxZoom: this.getOption('zoomTo') } const options = { maxZoom: this.getOption('zoomTo') }
this._leafletMap.fitBounds(bounds, options) this._leafletMap.fitBounds(bounds, options)

View file

@ -382,7 +382,7 @@ export default class Importer extends Utils.WithTemplate {
bounds.extend(featureBounds) bounds.extend(featureBounds)
} }
this.onSuccess(features.length) this.onSuccess(features.length)
layer.zoomTo(bounds) layer.zoomToBounds(bounds)
} }
} }
} }