Skip to content

Commit

Permalink
prevent leaflet from resetting center and zoom when browser resizes
Browse files Browse the repository at this point in the history
  • Loading branch information
falkoschindler committed Jan 24, 2025
1 parent 1fb2d12 commit afc56dd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 0 additions & 3 deletions nicegui/elements/leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ export default {
clearInterval(connectInterval);
}, 100);
},
updated() {
this.map?.setView(this.center, this.zoom);
},
methods: {
add_layer(layer, id) {
const l = L[layer.type](...layer.args);
Expand Down
4 changes: 2 additions & 2 deletions nicegui/elements/leaflet.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ def set_center(self, center: Tuple[float, float]) -> None:
return
self._props['center'] = center
if self._send_update_on_value_change:
self.update()
self.run_map_method('setView', center, self.zoom)

def set_zoom(self, zoom: int) -> None:
"""Set the zoom level of the map."""
if self._props['zoom'] == zoom:
return
self._props['zoom'] = zoom
if self._send_update_on_value_change:
self.update()
self.run_map_method('setView', self.center, zoom)

def remove_layer(self, layer: Layer) -> None:
"""Remove a layer from the map."""
Expand Down

0 comments on commit afc56dd

Please sign in to comment.