qmaps 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
qmaps-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021-2024 Dobatymo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
qmaps-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,44 @@
1
+ Metadata-Version: 2.4
2
+ Name: qmaps
3
+ Version: 0.0.1
4
+ Summary: Map widgets for Qt based on web view
5
+ Author-email: Dobatymo <Dobatymo@users.noreply.github.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.8
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ License-File: LICENSE
18
+ Requires-Dist: importlib-resources
19
+ Requires-Dist: PySide2>=5.14 ; extra == "qt5"
20
+ Requires-Dist: PySide6>=6.6 ; extra == "qt6"
21
+ Project-URL: Home, https://github.com/Dobatymo/qmaps
22
+ Provides-Extra: qt5
23
+ Provides-Extra: qt6
24
+
25
+ # QMaps
26
+
27
+ Qt maps widget implemented using a WebView. Various JavaScript libraries and mapping services are supported. Full Python to Javascript and JavaScript to Python calls supported.
28
+
29
+ ## Install
30
+
31
+ - Windows older than Windows 10 or Python 3.7: `pip install qmaps[qt5]`
32
+ - Windows 10 and above, Python 3.8 and above: `pip install qmaps[qt6]`
33
+
34
+ ## Examples
35
+
36
+ - `py examples/googlemaps.py` (GoogleMaps library using GoogleMaps tiles)
37
+ - `py examples/googlemaps_osm.py` (GoogleMaps library using OpenStreetMap tiles)
38
+ - `py examples/leaflet_osm.py` (Leaflet library using OpenStreetMap tiles)
39
+ - `py examples/openlayers_osm.py` (OpenLayers library using OpenStreetMap tiles)
40
+
41
+ ## Others
42
+
43
+ See <https://ircama.github.io/osm-carto-tutorials/map-client/> for more JavaScript maps implementations.
44
+
@@ -0,0 +1,66 @@
1
+ [build-system]
2
+ build-backend = "flit_core.buildapi"
3
+ requires = [
4
+ "flit_core<4,>=3.2",
5
+ ]
6
+
7
+ [project]
8
+ name = "qmaps"
9
+ readme = "readme.md"
10
+ license = {file = "LICENSE"}
11
+ authors = [{name = "Dobatymo", email = "Dobatymo@users.noreply.github.com"}]
12
+ requires-python = ">=3.8"
13
+ classifiers = [
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Operating System :: OS Independent",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "Programming Language :: Python :: 3.8",
19
+ "Programming Language :: Python :: 3.9",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ ]
24
+ dynamic = [
25
+ "description",
26
+ "version",
27
+ ]
28
+ dependencies = [
29
+ "importlib-resources",
30
+ ]
31
+ [project.optional-dependencies]
32
+ qt5 = [
33
+ "PySide2>=5.14",
34
+ ]
35
+ qt6 = [
36
+ "PySide6>=6.6",
37
+ ]
38
+ [project.urls]
39
+ Home = "https://github.com/Dobatymo/qmaps"
40
+
41
+ [tool.black]
42
+ line-length = 120
43
+
44
+ [tool.ruff]
45
+ line-length = 120
46
+
47
+ [tool.isort]
48
+ profile = "black"
49
+ line_length = 120
50
+
51
+ [tool.mypy]
52
+ ignore_missing_imports = true
53
+ no_implicit_optional = true
54
+ warn_redundant_casts = true
55
+ warn_unused_configs = true
56
+ warn_unused_ignores = true
57
+ warn_unreachable = true
58
+
59
+ [tool.bandit]
60
+ skips = ["B101"]
61
+
62
+ [dependency-groups]
63
+ dev = [
64
+ "genutility[test]>=0.0.100",
65
+ "pytest>=8",
66
+ ]
@@ -0,0 +1,3 @@
1
+ """Map widgets for Qt based on web view"""
2
+
3
+ __version__ = "0.0.1"
@@ -0,0 +1,140 @@
1
+ import json
2
+ import logging
3
+ import webbrowser
4
+ from typing import Any, Optional, Sequence
5
+
6
+ try:
7
+ from PySide6 import QtCore, QtGui, QtWidgets
8
+ from PySide6.QtWebChannel import QWebChannel
9
+ from PySide6.QtWebEngineCore import QWebEnginePage
10
+ from PySide6.QtWebEngineWidgets import QWebEngineView
11
+ except ImportError:
12
+ from PySide2 import QtCore, QtGui, QtWidgets
13
+ from PySide2.QtWebChannel import QWebChannel
14
+ from PySide2.QtWebEngineWidgets import QWebEnginePage, QWebEngineView
15
+
16
+
17
+ logmap = {
18
+ QWebEnginePage.JavaScriptConsoleMessageLevel.InfoMessageLevel: logging.INFO,
19
+ QWebEnginePage.JavaScriptConsoleMessageLevel.WarningMessageLevel: logging.WARNING,
20
+ QWebEnginePage.JavaScriptConsoleMessageLevel.ErrorMessageLevel: logging.ERROR,
21
+ }
22
+
23
+ jslog = logging.getLogger("javascript")
24
+
25
+
26
+ def jsrepr(obj: Any) -> str:
27
+ if obj is None:
28
+ return "null"
29
+ elif isinstance(obj, str):
30
+ return repr(obj)
31
+ elif isinstance(obj, bool): # handle bool before int, since a bool is a int
32
+ return "true" if obj else "false"
33
+ elif isinstance(obj, (int, float)):
34
+ return str(obj)
35
+ else:
36
+ raise TypeError(f"Unhandled type: {type(obj)}")
37
+
38
+
39
+ def js_func_call(name: str, args: Sequence[Any]) -> str:
40
+ args = ", ".join(map(jsrepr, args))
41
+ return f"{name}({args});"
42
+
43
+
44
+ class QMapBasePage(QWebEnginePage):
45
+ accept_language = "en-US,en;q=0.9"
46
+
47
+ def __init__(
48
+ self, channel: QWebChannel, cache_dir: str, persistent_dir: str, parent: Optional[QtWidgets.QWidget] = None
49
+ ) -> None:
50
+ QWebEnginePage.__init__(self, parent)
51
+
52
+ self.profile().setCachePath(cache_dir)
53
+ self.profile().setPersistentStoragePath(persistent_dir)
54
+ self.profile().setHttpAcceptLanguage(self.accept_language) # important! otherwise OSM requests are blocked
55
+
56
+ self.setWebChannel(channel)
57
+
58
+ def acceptNavigationRequest(self, url: QtCore.QUrl, type: QWebEnginePage.NavigationType, isMainFrame: bool) -> bool:
59
+ scheme = url.scheme()
60
+ if type == QWebEnginePage.NavigationType.NavigationTypeLinkClicked and scheme in ("http", "https"):
61
+ urlstr = url.toEncoded()
62
+ logging.warning("Open <%s> in browser", urlstr)
63
+ webbrowser.open(urlstr)
64
+ return False
65
+ return True
66
+
67
+ def javaScriptConsoleMessage(
68
+ self, level: QWebEnginePage.JavaScriptConsoleMessageLevel, message: str, lineNumber: int, sourceID: str
69
+ ) -> None:
70
+ sourceID = self.parent().clean_log_url(sourceID)
71
+
72
+ if sourceID.startswith("data:"):
73
+ sourceID = sourceID[:20] + "..."
74
+
75
+ extra = {"sourceID": sourceID, "lineNumber": lineNumber}
76
+ jslog.log(logmap[level], message, extra=extra)
77
+
78
+ def run_script_async(self, script: str) -> None:
79
+ self.runJavaScript(script)
80
+
81
+ def run_script_sync(self, script: str) -> Any:
82
+ loop = QtCore.QEventLoop()
83
+ result: Optional[str] = None
84
+
85
+ def callback(arg: Optional[str]) -> None:
86
+ nonlocal result
87
+ result = arg
88
+ loop.quit()
89
+
90
+ self.runJavaScript(script, 0, callback)
91
+ loop.exec_()
92
+ if isinstance(result, str):
93
+ return json.loads(result)
94
+ else:
95
+ return None
96
+
97
+
98
+ class QMapBase(QWebEngineView):
99
+ def __init__(
100
+ self,
101
+ channel_name: str,
102
+ cache_dir: str = "cache",
103
+ persistent_dir: str = "persistent",
104
+ ) -> None:
105
+ QWebEngineView.__init__(self)
106
+ self.initialized = False
107
+
108
+ channel = QWebChannel(self)
109
+ page = QMapBasePage(channel, cache_dir, persistent_dir, self)
110
+ self.setPage(page)
111
+ self.loadFinished.connect(self.on_load_finished)
112
+
113
+ channel.registerObject(channel_name, self)
114
+
115
+ def contextMenuEvent(self, event: QtGui.QContextMenuEvent) -> None: # disable default QWebEngineView context menu
116
+ pass
117
+
118
+ def clean_log_url(self, url: str) -> str:
119
+ return url
120
+
121
+ def wait_until_ready(self) -> None:
122
+ if not self.initialized:
123
+ loop = QtCore.QEventLoop()
124
+ self.loadFinished.connect(loop.quit)
125
+ loop.exec_()
126
+
127
+ @QtCore.Slot(bool)
128
+ def on_load_finished(self, ok: bool) -> None:
129
+ if not ok:
130
+ raise RuntimeError("Could not initialize map")
131
+
132
+ self.initialized = True
133
+
134
+ def run_func_async(self, name: str, *args) -> None:
135
+ script = js_func_call(name, args)
136
+ self.page().run_script_async(script)
137
+
138
+ def run_func_sync(self, name: str, *args) -> Any:
139
+ script = js_func_call(name, args)
140
+ return self.page().run_script_sync(script)
@@ -0,0 +1,167 @@
1
+ from typing import Optional, Tuple
2
+
3
+ from importlib_resources import files
4
+
5
+ try:
6
+ from PySide6.QtCore import Signal, Slot
7
+ except ImportError:
8
+ from PySide2.QtCore import Signal, Slot
9
+
10
+
11
+ from .base import QMapBase
12
+
13
+ """ GoogleMaps QWebEngineView supporting GoogleMaps, OSM
14
+ Google Maps JavaScript API: https://developers.google.com/maps/documentation/javascript/overview
15
+ """
16
+
17
+
18
+ class QGoogleMapsBase(QMapBase):
19
+ map_click = Signal(float, float)
20
+ map_contextmenu = Signal(float, float)
21
+ map_dblclick = Signal(float, float)
22
+ map_move = Signal(float, float)
23
+ map_moveend = Signal(float, float)
24
+ map_movestart = Signal(float, float)
25
+ map_rightclick = Signal(float, float)
26
+ map_zoom = Signal(int)
27
+
28
+ marker_move = Signal(str, float, float)
29
+ marker_moveend = Signal(str, float, float)
30
+ marker_movestart = Signal(str, float, float)
31
+ marker_click = Signal(str, float, float)
32
+ marker_dblclick = Signal(str, float, float)
33
+ marker_rightclick = Signal(str, float, float)
34
+
35
+ # JavaScript API
36
+
37
+ @Slot(float, float)
38
+ def on_click(self, lat: float, lng: float) -> None:
39
+ self.map_click.emit(lat, lng)
40
+
41
+ @Slot(float, float)
42
+ def on_contextmenu(self, lat: float, lng: float) -> None:
43
+ self.map_contextmenu.emit(lat, lng)
44
+
45
+ @Slot(float, float)
46
+ def on_dblclick(self, lat: float, lng: float) -> None:
47
+ self.map_dblclick.emit(lat, lng)
48
+
49
+ @Slot(float, float)
50
+ def on_move(self, lat: float, lng: float) -> None:
51
+ self.map_move.emit(lat, lng)
52
+
53
+ @Slot(float, float)
54
+ def on_moveend(self, lat: float, lng: float) -> None:
55
+ self.map_moveend.emit(lat, lng)
56
+
57
+ @Slot(float, float)
58
+ def on_movestart(self, lat: float, lng: float) -> None:
59
+ self.map_movestart.emit(lat, lng)
60
+
61
+ @Slot(float, float)
62
+ def on_rightclick(self, lat: float, lng: float) -> None:
63
+ self.map_rightclick.emit(lat, lng)
64
+
65
+ @Slot(int)
66
+ def on_zoom(self, zoom: int) -> None:
67
+ self.map_zoom.emit(zoom)
68
+
69
+ @Slot(str, float, float)
70
+ def on_marker_move(self, key: str, lat: float, lng: float) -> None:
71
+ self.marker_move.emit(key, lat, lng)
72
+
73
+ @Slot(str, float, float)
74
+ def on_marker_moveend(self, key: str, lat: float, lng: float) -> None:
75
+ self.marker_moveend.emit(key, lat, lng)
76
+
77
+ @Slot(str, float, float)
78
+ def on_marker_movestart(self, key: str, lat: float, lng: float) -> None:
79
+ self.marker_movestart.emit(key, lat, lng)
80
+
81
+ @Slot(str, float, float)
82
+ def on_marker_click(self, key: str, lat: float, lng: float) -> None:
83
+ self.marker_click.emit(key, lat, lng)
84
+
85
+ @Slot(str, float, float)
86
+ def on_marker_dblclick(self, key: str, lat: float, lng: float) -> None:
87
+ self.marker_dblclick.emit(key, lat, lng)
88
+
89
+ @Slot(str, float, float)
90
+ def on_marker_rightclick(self, key: str, lat: float, lng: float) -> None:
91
+ self.marker_rightclick.emit(key, lat, lng)
92
+
93
+ # Python API
94
+
95
+ def get_center(self) -> Tuple[float, float]:
96
+ lat, lon = self.run_func_sync("get_center")
97
+ return (lat, lon)
98
+
99
+ def set_center(self, latitude: float, longitude: float) -> None:
100
+ self.run_func_async("set_center", latitude, longitude)
101
+
102
+ def set_zoom(self, zoom: int) -> None:
103
+ self.run_func_async("set_zoom", zoom)
104
+
105
+ def move_marker(self, key: str, latitude: float, longitude: float) -> None:
106
+ self.run_func_async("move_marker", key, latitude, longitude)
107
+
108
+ def change_marker(
109
+ self,
110
+ key: str,
111
+ clickable: bool = True,
112
+ draggable: bool = False,
113
+ label: Optional[str] = None,
114
+ title: Optional[str] = None,
115
+ ) -> None:
116
+ self.run_func_async("change_marker", key, clickable, draggable, label, title)
117
+
118
+ def delete_marker(self, key: str) -> None:
119
+ self.run_func_async("delete_marker", key)
120
+
121
+ def add_marker(
122
+ self,
123
+ key: str,
124
+ latitude: float,
125
+ longitude: float,
126
+ clickable: bool = True,
127
+ draggable: bool = False,
128
+ label: Optional[str] = None,
129
+ title: Optional[str] = None,
130
+ ) -> None:
131
+ self.run_func_async("add_marker", key, latitude, longitude, clickable, draggable, label, title)
132
+
133
+
134
+ class QGoogleMapsOSM(QGoogleMapsBase):
135
+ """QWidget (QWebEngineView) which renders OpenStreetMap using GoogleMaps"""
136
+
137
+ HTML = files(__package__).joinpath("resources/googlemaps_osm.htm").read_text(encoding="utf-8")
138
+
139
+ def __init__(self, latitude: float = 0, longitude: float = 0, zoom: int = 0) -> None:
140
+ super().__init__("qGoogleMaps")
141
+
142
+ html = self.HTML
143
+ html = html.replace("'<latitude>'", str(latitude))
144
+ html = html.replace("'<longitude>'", str(longitude))
145
+ html = html.replace("'<zoom>'", str(zoom))
146
+ self.page().setHtml(html)
147
+
148
+
149
+ class QGoogleMapsGoogleMaps(QGoogleMapsBase):
150
+ """QWidget (QWebEngineView) which renders GoogleMaps using GoogleMaps"""
151
+
152
+ HTML = files(__package__).joinpath("resources/googlemaps_googlemaps.htm").read_text(encoding="utf-8")
153
+
154
+ def __init__(self, api_key: str, latitude: float = 0, longitude: float = 0, zoom: int = 0) -> None:
155
+ super().__init__("qGoogleMaps")
156
+
157
+ self.api_key = api_key
158
+
159
+ html = self.HTML
160
+ html = html.replace("<YOUR_API_KEY>", api_key)
161
+ html = html.replace("'<latitude>'", str(latitude))
162
+ html = html.replace("'<longitude>'", str(longitude))
163
+ html = html.replace("'<zoom>'", str(zoom))
164
+ self.page().setHtml(html)
165
+
166
+ def clean_log_url(self, url: str) -> str:
167
+ return url.replace(self.api_key, "<redacted>")
@@ -0,0 +1,173 @@
1
+ import json
2
+ from typing import Optional, Sequence, Tuple, Union
3
+
4
+ from importlib_resources import files
5
+
6
+ try:
7
+ from PySide6 import QtCore
8
+ except ImportError:
9
+ from PySide2 import QtCore
10
+
11
+ from .base import QMapBase
12
+
13
+ """ Leaflet QWebEngineView supporting OSM
14
+ """
15
+
16
+ CoordsT = Sequence[Tuple[float, float]]
17
+ NumberT = Union[int, float]
18
+
19
+ DEFAULT_MARKER_TITLE: str = ""
20
+ DEFAULT_MARKER_OPACITY: NumberT = 1.0
21
+ DEFAULT_PATH_COLOR: str = "#3388ff"
22
+ DEFAULT_PATH_WEIGHT: NumberT = 3
23
+ DEFAULT_PATH_FILL_COLOR: str = "*"
24
+ DEFAULT_PATH_FILL_OPACITY: NumberT = 0.2
25
+ DEFAULT_PATH_OPACITY: NumberT = 1.0
26
+ DEFAULT_IMAGEOVERLAY_OPACITY: NumberT = 1.0
27
+ DEFAULT_IMAGEOVERLAY_INTERACTIVE: bool = False
28
+
29
+
30
+ class QLeafletOSM(QMapBase):
31
+ """QWidget (QWebEngineView) which renders OpenStreetMap using Leaflet"""
32
+
33
+ HTML = files(__package__).joinpath("resources/leaflet_osm.htm").read_text(encoding="utf-8")
34
+
35
+ map_move = QtCore.Signal(float, float)
36
+ map_moveend = QtCore.Signal(float, float)
37
+ map_movestart = QtCore.Signal(float, float)
38
+ map_click = QtCore.Signal(float, float)
39
+ map_contextmenu = QtCore.Signal(float, float)
40
+ map_dblclick = QtCore.Signal(float, float)
41
+ map_zoom = QtCore.Signal(float, float, int)
42
+
43
+ def __init__(self, latitude: float = 0, longitude: float = 0, zoom: int = 0) -> None:
44
+ super().__init__("qOSM")
45
+
46
+ html = self.HTML
47
+ html = html.replace("'<latitude>'", str(latitude))
48
+ html = html.replace("'<longitude>'", str(longitude))
49
+ html = html.replace("'<zoom>'", str(zoom))
50
+ self.page().setHtml(html)
51
+
52
+ # JavaScript API
53
+
54
+ @QtCore.Slot(float, float)
55
+ def on_move(self, lat: float, lng: float) -> None:
56
+ self.map_move.emit(lat, lng)
57
+
58
+ @QtCore.Slot(float, float)
59
+ def on_moveend(self, lat: float, lng: float) -> None:
60
+ self.map_moveend.emit(lat, lng)
61
+
62
+ @QtCore.Slot(float, float)
63
+ def on_movestart(self, lat: float, lng: float) -> None:
64
+ self.map_movestart.emit(lat, lng)
65
+
66
+ @QtCore.Slot(float, float)
67
+ def on_click(self, lat: float, lng: float) -> None:
68
+ self.map_click.emit(lat, lng)
69
+
70
+ @QtCore.Slot(float, float)
71
+ def on_contextmenu(self, lat: float, lng: float) -> None:
72
+ self.map_contextmenu.emit(lat, lng)
73
+
74
+ @QtCore.Slot(float, float)
75
+ def on_dblclick(self, lat: float, lng: float) -> None:
76
+ self.map_dblclick.emit(lat, lng)
77
+
78
+ @QtCore.Slot(float, float, int)
79
+ def on_zoom(self, lat: float, lng: float, zoom: int) -> None:
80
+ self.map_zoom.emit(lat, lng, zoom)
81
+
82
+ # Sync Python API
83
+
84
+ def get_center(self) -> dict:
85
+ return self.run_func_sync("get_center")
86
+
87
+ def get_zoom(self) -> int:
88
+ return self.run_func_sync("get_zoom")
89
+
90
+ def get_bounds(self) -> Tuple[dict, dict]:
91
+ a, b = self.run_func_sync("get_bounds")
92
+ return a, b
93
+
94
+ # Async Python API
95
+
96
+ def set_view(self, lat: float, lng: float, zoom: int) -> None:
97
+ self.run_func_async("set_view", lat, lng, zoom)
98
+
99
+ def set_zoom(self, zoom: int) -> None:
100
+ self.run_func_async("set_zoom", zoom)
101
+
102
+ def fit_bounds(self, lat1: float, lng1: float, lat2: float, lng2: float) -> None:
103
+ self.run_func_async("fit_bounds", lat1, lng1, lat2, lng2)
104
+
105
+ def pan_to(self, lat: float, lng: float) -> None:
106
+ self.run_func_async("pan_to", lat, lng)
107
+
108
+ def add_marker(
109
+ self,
110
+ key: str,
111
+ lat: float,
112
+ lng: float,
113
+ title: str = DEFAULT_MARKER_TITLE,
114
+ opacity: NumberT = DEFAULT_MARKER_OPACITY,
115
+ popup: Optional[str] = None,
116
+ ) -> None:
117
+ self.run_func_async("add_marker", key, lat, lng, title, opacity, popup)
118
+
119
+ def add_circle(
120
+ self,
121
+ key: str,
122
+ lat: float,
123
+ lng: float,
124
+ radius: int,
125
+ color: str = DEFAULT_PATH_COLOR,
126
+ fill_color: str = DEFAULT_PATH_FILL_COLOR,
127
+ fill_opacity: NumberT = DEFAULT_PATH_FILL_OPACITY,
128
+ popup: Optional[str] = None,
129
+ ) -> None:
130
+ self.run_func_async("add_circle", key, lat, lng, radius, color, fill_color, fill_opacity, popup)
131
+
132
+ def add_polygon(
133
+ self,
134
+ key: str,
135
+ latlngs: Union[CoordsT, Sequence[CoordsT], Sequence[Sequence[CoordsT]]],
136
+ smooth_factor: NumberT = 1.0,
137
+ color: str = DEFAULT_PATH_COLOR,
138
+ weight: NumberT = DEFAULT_PATH_WEIGHT,
139
+ popup: Optional[str] = None,
140
+ ) -> None:
141
+ latlng_list = json.dumps(latlngs)
142
+ self.run_func_async("add_polygon", key, latlng_list, smooth_factor, color, weight, popup)
143
+
144
+ def add_polyline(
145
+ self,
146
+ key: str,
147
+ latlngs: Union[CoordsT, Sequence[CoordsT]],
148
+ smooth_factor: NumberT = 1.0,
149
+ color: str = DEFAULT_PATH_COLOR,
150
+ weight: NumberT = DEFAULT_PATH_WEIGHT,
151
+ popup: Optional[str] = None,
152
+ ) -> None:
153
+ latlng_list = json.dumps(latlngs)
154
+ self.run_func_async("add_polyline", key, latlng_list, smooth_factor, color, weight, popup)
155
+
156
+ def add_image_url(
157
+ self,
158
+ key: str,
159
+ image_url: str,
160
+ lat1: float,
161
+ lng1: float,
162
+ lat2: float,
163
+ lng2: float,
164
+ opacity: NumberT = DEFAULT_IMAGEOVERLAY_OPACITY,
165
+ interactive: bool = DEFAULT_IMAGEOVERLAY_INTERACTIVE,
166
+ ) -> None:
167
+ self.run_func_async("add_image_url", key, image_url, lat1, lng1, lat2, lng2, opacity, interactive)
168
+
169
+ def remove_layer(self, key: str) -> None:
170
+ self.run_func_async("remove_layer", key)
171
+
172
+ def open_popup(self, key: str) -> None:
173
+ self.run_func_async("open_popup", key)