leaflet.py 630 B

123456789101112131415161718
  1. from typing import Tuple
  2. from nicegui import ui
  3. from nicegui.dependencies import register_component
  4. from nicegui.element import Element
  5. register_component('leaflet', __file__, 'leaflet.js')
  6. class leaflet(Element):
  7. def __init__(self) -> None:
  8. super().__init__('leaflet')
  9. ui.add_head_html('<link href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" rel="stylesheet"/>')
  10. ui.add_head_html('<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js"></script>')
  11. def set_location(self, location: Tuple[float, float]) -> None:
  12. self.run_method('set_location', location[0], location[1])