|
@@ -1,5 +1,5 @@
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
-from typing import Any, List, Tuple, cast
|
|
|
|
|
|
+from typing import Any, List, Tuple, Union, cast
|
|
|
|
|
|
from typing_extensions import Self
|
|
from typing_extensions import Self
|
|
|
|
|
|
@@ -23,7 +23,7 @@ class Leaflet(Element, component='leaflet.js'):
|
|
location: Tuple[float, float] = (0, 0),
|
|
location: Tuple[float, float] = (0, 0),
|
|
zoom: int = 13,
|
|
zoom: int = 13,
|
|
*,
|
|
*,
|
|
- show_draw_toolbar: bool = False,
|
|
|
|
|
|
+ draw_control: Union[bool, dict] = False,
|
|
) -> None:
|
|
) -> None:
|
|
"""Leaflet map
|
|
"""Leaflet map
|
|
|
|
|
|
@@ -31,7 +31,7 @@ class Leaflet(Element, component='leaflet.js'):
|
|
|
|
|
|
:param location: initial location of the map
|
|
:param location: initial location of the map
|
|
:param zoom: initial zoom level of the map
|
|
:param zoom: initial zoom level of the map
|
|
- :param show_draw_toolbar: whether to show the draw control toolbar
|
|
|
|
|
|
+ :param draw_control: whether to show the draw toolbar (default: False)
|
|
"""
|
|
"""
|
|
super().__init__()
|
|
super().__init__()
|
|
self.add_resource(Path(__file__).parent / 'lib' / 'leaflet')
|
|
self.add_resource(Path(__file__).parent / 'lib' / 'leaflet')
|
|
@@ -41,7 +41,7 @@ class Leaflet(Element, component='leaflet.js'):
|
|
|
|
|
|
self.set_location(location)
|
|
self.set_location(location)
|
|
self.set_zoom(zoom)
|
|
self.set_zoom(zoom)
|
|
- self.show_draw_toolbar = show_draw_toolbar
|
|
|
|
|
|
+ self.draw_control = draw_control
|
|
|
|
|
|
self.is_initialized = False
|
|
self.is_initialized = False
|
|
self.on('init', self._handle_init)
|
|
self.on('init', self._handle_init)
|
|
@@ -89,8 +89,8 @@ class Leaflet(Element, component='leaflet.js'):
|
|
'lng': self.location[1],
|
|
'lng': self.location[1],
|
|
},
|
|
},
|
|
'zoom': self.zoom,
|
|
'zoom': self.zoom,
|
|
- 'drawControl': self.show_draw_toolbar,
|
|
|
|
}
|
|
}
|
|
|
|
+ self._props['draw_control'] = self.draw_control
|
|
super().update()
|
|
super().update()
|
|
|
|
|
|
def _handle_delete(self) -> None:
|
|
def _handle_delete(self) -> None:
|