Skip to content

Commit f3a31a3

Browse files
committed
1 parent 6d8b2ee commit f3a31a3

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

ngwidgets/leaflet_map.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
class LeafletMap(ui.leaflet):
1111
"""Enhanced Leaflet map with additional functionality"""
1212

13-
def __init__(self, center: Tuple[float, float]=(51.505, -0.09), zoom: int=9,
14-
with_draw_control: bool=True, classes: str="h-96"):
13+
def __init__(self,
14+
center: Tuple[float, float]=(51.505, -0.09),
15+
zoom: int=9,
16+
with_draw_control: bool=True,
17+
classes: str="w-full h-96",
18+
debug:bool=False):
1519
"""Initialize enhanced map
1620
1721
Args:
@@ -36,6 +40,7 @@ def __init__(self, center: Tuple[float, float]=(51.505, -0.09), zoom: int=9,
3640
} if with_draw_control else None
3741

3842
super().__init__(center=center, zoom=zoom, draw_control=draw_control)
43+
self.debug=debug
3944
self.classes(classes)
4045
self.on('map-click', self._handle_click)
4146
self.on('draw:created', self._handle_draw)
@@ -53,7 +58,8 @@ def _handle_draw(self, e: events.GenericEventArguments):
5358
coords = e.args['layer'].get('_latlng') or e.args['layer'].get('_latlngs')
5459
layer_id = e.args['layer'].get('_leaflet_id')
5560
msg=f'Drawn a {layer_type} with id {layer_id} at {coords}'
56-
logging.warn(msg)
61+
if self.debug:
62+
logging.warn(msg)
5763
ui.notify(msg)
5864

5965
def draw_path(self, path: List[Tuple[float, float]], options: Dict = None) -> Any:

ngwidgets/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Version:
1717
name = "ngwidgets"
1818
version = ngwidgets.__version__
1919
date = "2023-09-10"
20-
updated = "2024-12-07"
20+
updated = "2024-12-09"
2121
description = "NiceGUI widgets"
2222

2323
authors = "Wolfgang Fahl"

ngwidgets/widgets_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ async def show():
794794
ui.button(icon='zoom_in', on_click=lambda: setattr(self.map, 'zoom', self.map.zoom + 1))
795795
ui.button(icon='zoom_out', on_click=lambda: setattr(self.map, 'zoom', self.map.zoom - 1))
796796
#ui.button('Fit world', on_click=lambda: self.map.run_map_method('fitWorld'))
797-
ui.button('Clear layers', on_click=lambda: self.map.layers.clear())
797+
ui.button('Clear layers', on_click=lambda: self.map.clear_layers())
798798

799799
await self.setup_content_div(show)
800800

0 commit comments

Comments
 (0)