Skip to content

Commit

Permalink
fix(#2391): split zoomTo to accept bounds (#2394)
Browse files Browse the repository at this point in the history
Since
de92166#diff-4a01a166046bdf7e4ea7d41d97cd82a57c82f63d10d1697f76e6fe22bfa769ebR954
we were calling it with bounds but also with the click event sometimes.
  • Loading branch information
davidbgk authored Dec 20, 2024
2 parents 17e6cf7 + 7cb6c0c commit 49d1dbf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions umap/static/umap/js/modules/data/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -950,9 +950,13 @@ export class DataLayer extends ServerStored {
else this.hide()
}

zoomTo(bounds) {
zoomTo() {
if (!this.isVisible()) return
bounds = bounds || this.layer.getBounds()
const bounds = this.layer.getBounds()
this.zoomToBounds(bounds)
}

zoomToBounds(bounds) {
if (bounds.isValid()) {
const options = { maxZoom: this.getOption('zoomTo') }
this._leafletMap.fitBounds(bounds, options)
Expand Down
2 changes: 1 addition & 1 deletion umap/static/umap/js/modules/importer.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ export default class Importer extends Utils.WithTemplate {
bounds.extend(featureBounds)
}
this.onSuccess(features.length)
layer.zoomTo(bounds)
layer.zoomToBounds(bounds)
}
}
}

0 comments on commit 49d1dbf

Please sign in to comment.