flet-map 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl
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.
Potentially problematic release.
This version of flet-map might be problematic. Click here for more details.
- flet_map/__init__.py +30 -1
- flet_map/circle_layer.py +156 -0
- flet_map/map.py +674 -0
- flet_map/map_layer.py +26 -0
- flet_map/marker_layer.py +183 -0
- flet_map/polygon_layer.py +262 -0
- flet_map/polyline_layer.py +292 -0
- flet_map/rich_attribution.py +141 -0
- flet_map/simple_attribution.py +86 -0
- flet_map/text_source_attribution.py +87 -0
- flet_map/tile_layer.py +278 -0
- flet_map-0.1.0.dist-info/METADATA +168 -0
- flet_map-0.1.0.dist-info/RECORD +34 -0
- {flet_map-0.0.1.dist-info → flet_map-0.1.0.dist-info}/WHEEL +2 -1
- flet_map-0.1.0.dist-info/top_level.txt +2 -0
- flutter/flet_map/CHANGELOG.md +3 -0
- flutter/flet_map/LICENSE +201 -0
- flutter/flet_map/README.md +3 -0
- flutter/flet_map/analysis_options.yaml +4 -0
- flutter/flet_map/lib/flet_map.dart +3 -0
- flutter/flet_map/lib/src/circle_layer.dart +43 -0
- flutter/flet_map/lib/src/create_control.dart +70 -0
- flutter/flet_map/lib/src/map.dart +140 -0
- flutter/flet_map/lib/src/marker_layer.dart +50 -0
- flutter/flet_map/lib/src/polygon_layer.dart +68 -0
- flutter/flet_map/lib/src/polyline_layer.dart +80 -0
- flutter/flet_map/lib/src/rich_attribution.dart +61 -0
- flutter/flet_map/lib/src/simple_attribution.dart +37 -0
- flutter/flet_map/lib/src/text_source_attribution.dart +29 -0
- flutter/flet_map/lib/src/tile_layer.dart +80 -0
- flutter/flet_map/lib/src/utils/attribution_alignment.dart +12 -0
- flutter/flet_map/lib/src/utils/map.dart +280 -0
- flutter/flet_map/pubspec.lock +831 -0
- flutter/flet_map/pubspec.yaml +21 -0
- .DS_Store +0 -0
- flet_map/.DS_Store +0 -0
- flet_map-0.0.1.dist-info/.DS_Store +0 -0
- flet_map-0.0.1.dist-info/METADATA +0 -14
- flet_map-0.0.1.dist-info/RECORD +0 -7
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from typing import Any, List, Optional, Union
|
|
4
|
+
|
|
5
|
+
from flet.core.control import Control, OptionalNumber
|
|
6
|
+
from flet_map.map import MapLatitudeLongitude
|
|
7
|
+
from flet_map.map_layer import MapLayer
|
|
8
|
+
from flet.core.ref import Ref
|
|
9
|
+
from flet.core.types import ColorEnums, ColorValue, StrokeCap, StrokeJoin
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class PatternFit(Enum):
|
|
13
|
+
SCALE_DOWN = "scaleDown"
|
|
14
|
+
SCALE_UP = "scaleUp"
|
|
15
|
+
APPEND_DOT = "appendDot"
|
|
16
|
+
EXTEND_FINAL_DASH = "extendFinalDash"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@dataclass
|
|
20
|
+
class StrokePattern:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass
|
|
25
|
+
class SolidStrokePattern(StrokePattern):
|
|
26
|
+
def __post_init__(self):
|
|
27
|
+
self.type = "solid"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class DashedStrokePattern(StrokePattern):
|
|
32
|
+
segments: Optional[List[Union[float, int]]] = None
|
|
33
|
+
pattern_fit: Optional[PatternFit] = PatternFit.SCALE_UP
|
|
34
|
+
|
|
35
|
+
def __post_init__(self):
|
|
36
|
+
self.type = "dashed"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
@dataclass
|
|
40
|
+
class DottedStrokePattern(StrokePattern):
|
|
41
|
+
spacing_factor: OptionalNumber = None
|
|
42
|
+
pattern_fit: Optional[PatternFit] = PatternFit.SCALE_UP
|
|
43
|
+
|
|
44
|
+
def __post_init__(self):
|
|
45
|
+
self.type = "dotted"
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class PolylineMarker(Control):
|
|
49
|
+
"""
|
|
50
|
+
A marker for the PolylineLayer.
|
|
51
|
+
|
|
52
|
+
-----
|
|
53
|
+
|
|
54
|
+
Online docs: https://flet.dev/docs/controls/mappolylinemarker
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(
|
|
58
|
+
self,
|
|
59
|
+
coordinates: List[MapLatitudeLongitude],
|
|
60
|
+
colors_stop: Optional[List[Union[float, int]]] = None,
|
|
61
|
+
gradient_colors: Optional[List[str]] = None,
|
|
62
|
+
border_color: Optional[ColorValue] = None,
|
|
63
|
+
color: Optional[ColorValue] = None,
|
|
64
|
+
stroke_width: OptionalNumber = None,
|
|
65
|
+
border_stroke_width: OptionalNumber = None,
|
|
66
|
+
use_stroke_width_in_meter: Optional[bool] = None,
|
|
67
|
+
stroke_pattern: Optional[StrokePattern] = None,
|
|
68
|
+
stroke_cap: Optional[StrokeCap] = None,
|
|
69
|
+
stroke_join: Optional[StrokeJoin] = None,
|
|
70
|
+
#
|
|
71
|
+
# Control
|
|
72
|
+
#
|
|
73
|
+
ref: Optional[Ref] = None,
|
|
74
|
+
visible: Optional[bool] = None,
|
|
75
|
+
data: Any = None,
|
|
76
|
+
):
|
|
77
|
+
Control.__init__(
|
|
78
|
+
self,
|
|
79
|
+
ref=ref,
|
|
80
|
+
visible=visible,
|
|
81
|
+
data=data,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
self.coordinates = coordinates
|
|
85
|
+
self.border_color = border_color
|
|
86
|
+
self.color = color
|
|
87
|
+
self.border_stroke_width = border_stroke_width
|
|
88
|
+
self.stroke_width = stroke_width
|
|
89
|
+
self.stroke_cap = stroke_cap
|
|
90
|
+
self.stroke_join = stroke_join
|
|
91
|
+
self.colors_stop = colors_stop
|
|
92
|
+
self.gradient_colors = gradient_colors
|
|
93
|
+
self.use_stroke_width_in_meter = use_stroke_width_in_meter
|
|
94
|
+
self.stroke_pattern = stroke_pattern
|
|
95
|
+
|
|
96
|
+
def _get_control_name(self):
|
|
97
|
+
return "map_polyline_marker"
|
|
98
|
+
|
|
99
|
+
def before_update(self):
|
|
100
|
+
super().before_update()
|
|
101
|
+
self._set_attr_json("coordinates", self.__coordinates)
|
|
102
|
+
if isinstance(self.__colors_stop, list):
|
|
103
|
+
self._set_attr_json("colorsStop", self.__colors_stop)
|
|
104
|
+
if isinstance(self.__gradient_colors, list):
|
|
105
|
+
self._set_attr_json("gradientColors", self.__gradient_colors)
|
|
106
|
+
self._set_attr_json("strokePattern", self.__stroke_pattern)
|
|
107
|
+
|
|
108
|
+
# stroke_cap
|
|
109
|
+
@property
|
|
110
|
+
def stroke_cap(self) -> Optional[StrokeCap]:
|
|
111
|
+
return self.__stroke_cap
|
|
112
|
+
|
|
113
|
+
@stroke_cap.setter
|
|
114
|
+
def stroke_cap(self, value: Optional[StrokeCap]):
|
|
115
|
+
self.__stroke_cap = value
|
|
116
|
+
self._set_enum_attr("strokeCap", value, StrokeCap)
|
|
117
|
+
|
|
118
|
+
# gradient_colors
|
|
119
|
+
@property
|
|
120
|
+
def gradient_colors(self) -> Optional[List[str]]:
|
|
121
|
+
return self.__gradient_colors
|
|
122
|
+
|
|
123
|
+
@gradient_colors.setter
|
|
124
|
+
def gradient_colors(self, value: Optional[List[str]]):
|
|
125
|
+
self.__gradient_colors = value
|
|
126
|
+
|
|
127
|
+
# stroke_pattern
|
|
128
|
+
@property
|
|
129
|
+
def stroke_pattern(self) -> Optional[StrokePattern]:
|
|
130
|
+
return self.__stroke_pattern
|
|
131
|
+
|
|
132
|
+
@stroke_pattern.setter
|
|
133
|
+
def stroke_pattern(self, value: Optional[StrokePattern]):
|
|
134
|
+
self.__stroke_pattern = value
|
|
135
|
+
|
|
136
|
+
# colors_stop
|
|
137
|
+
@property
|
|
138
|
+
def colors_stop(self) -> Optional[List[Union[float, int]]]:
|
|
139
|
+
return self.__colors_stop
|
|
140
|
+
|
|
141
|
+
@colors_stop.setter
|
|
142
|
+
def colors_stop(self, value: Optional[List[Union[float, int]]]):
|
|
143
|
+
self.__colors_stop = value
|
|
144
|
+
|
|
145
|
+
# stroke_join
|
|
146
|
+
@property
|
|
147
|
+
def stroke_join(self) -> Optional[StrokeJoin]:
|
|
148
|
+
return self.__stroke_join
|
|
149
|
+
|
|
150
|
+
@stroke_join.setter
|
|
151
|
+
def stroke_join(self, value: Optional[StrokeJoin]):
|
|
152
|
+
self.__stroke_join = value
|
|
153
|
+
self._set_enum_attr("strokeJoin", value, StrokeJoin)
|
|
154
|
+
|
|
155
|
+
# use_stroke_width_in_meter
|
|
156
|
+
@property
|
|
157
|
+
def use_stroke_width_in_meter(self) -> bool:
|
|
158
|
+
return self._get_attr(
|
|
159
|
+
"useStrokeWidthInMeter", data_type="bool", def_value=False
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
@use_stroke_width_in_meter.setter
|
|
163
|
+
def use_stroke_width_in_meter(self, value: Optional[bool]):
|
|
164
|
+
self._set_attr("useStrokeWidthInMeter", value)
|
|
165
|
+
|
|
166
|
+
# color
|
|
167
|
+
@property
|
|
168
|
+
def color(self) -> Optional[ColorValue]:
|
|
169
|
+
return self.__color
|
|
170
|
+
|
|
171
|
+
@color.setter
|
|
172
|
+
def color(self, value: Optional[ColorValue]):
|
|
173
|
+
self.__color = value
|
|
174
|
+
self._set_enum_attr("color", value, ColorEnums)
|
|
175
|
+
|
|
176
|
+
# border_color
|
|
177
|
+
@property
|
|
178
|
+
def border_color(self) -> Optional[ColorValue]:
|
|
179
|
+
return self.__border_color
|
|
180
|
+
|
|
181
|
+
@border_color.setter
|
|
182
|
+
def border_color(self, value: Optional[ColorValue]):
|
|
183
|
+
self.__border_color = value
|
|
184
|
+
self._set_enum_attr("borderColor", value, ColorEnums)
|
|
185
|
+
|
|
186
|
+
# border_stroke_width
|
|
187
|
+
@property
|
|
188
|
+
def border_stroke_width(self) -> float:
|
|
189
|
+
return self._get_attr("borderStrokeWidth", data_type="float", def_value=0.0)
|
|
190
|
+
|
|
191
|
+
@border_stroke_width.setter
|
|
192
|
+
def border_stroke_width(self, value: OptionalNumber):
|
|
193
|
+
assert value is None or value >= 0, "border_stroke_width cannot be negative"
|
|
194
|
+
self._set_attr("borderStrokeWidth", value)
|
|
195
|
+
|
|
196
|
+
# stroke_width
|
|
197
|
+
@property
|
|
198
|
+
def stroke_width(self) -> float:
|
|
199
|
+
return self._get_attr("strokeWidth", data_type="float", def_value=1.0)
|
|
200
|
+
|
|
201
|
+
@stroke_width.setter
|
|
202
|
+
def stroke_width(self, value: OptionalNumber):
|
|
203
|
+
assert value is None or value >= 0, "stroke_width cannot be negative"
|
|
204
|
+
self._set_attr("strokeWidth", value)
|
|
205
|
+
|
|
206
|
+
# coordinates
|
|
207
|
+
@property
|
|
208
|
+
def coordinates(self) -> List[MapLatitudeLongitude]:
|
|
209
|
+
return self.__coordinates
|
|
210
|
+
|
|
211
|
+
@coordinates.setter
|
|
212
|
+
def coordinates(self, value: List[MapLatitudeLongitude]):
|
|
213
|
+
self.__coordinates = value
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
class PolylineLayer(MapLayer):
|
|
217
|
+
"""
|
|
218
|
+
A layer to display PolylineMarkers.
|
|
219
|
+
|
|
220
|
+
-----
|
|
221
|
+
|
|
222
|
+
Online docs: https://flet.dev/docs/controls/mappolylinelayer
|
|
223
|
+
"""
|
|
224
|
+
|
|
225
|
+
def __init__(
|
|
226
|
+
self,
|
|
227
|
+
polylines: List[PolylineMarker],
|
|
228
|
+
culling_margin: OptionalNumber = None,
|
|
229
|
+
min_hittable_radius: OptionalNumber = None,
|
|
230
|
+
simplify_tolerance: OptionalNumber = None,
|
|
231
|
+
#
|
|
232
|
+
# MapLayer
|
|
233
|
+
#
|
|
234
|
+
ref: Optional[Ref] = None,
|
|
235
|
+
visible: Optional[bool] = None,
|
|
236
|
+
data: Any = None,
|
|
237
|
+
):
|
|
238
|
+
MapLayer.__init__(
|
|
239
|
+
self,
|
|
240
|
+
ref=ref,
|
|
241
|
+
visible=visible,
|
|
242
|
+
data=data,
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
self.polylines = polylines
|
|
246
|
+
self.culling_margin = culling_margin
|
|
247
|
+
self.min_hittable_radius = min_hittable_radius
|
|
248
|
+
self.simplify_tolerance = simplify_tolerance
|
|
249
|
+
|
|
250
|
+
def _get_control_name(self):
|
|
251
|
+
return "map_polyline_layer"
|
|
252
|
+
|
|
253
|
+
def _get_children(self):
|
|
254
|
+
return self.__polylines
|
|
255
|
+
|
|
256
|
+
# polylines
|
|
257
|
+
@property
|
|
258
|
+
def polylines(self) -> List[PolylineMarker]:
|
|
259
|
+
return self.__polylines
|
|
260
|
+
|
|
261
|
+
@polylines.setter
|
|
262
|
+
def polylines(self, value: List[PolylineMarker]):
|
|
263
|
+
self.__polylines = value
|
|
264
|
+
|
|
265
|
+
# culling_margin
|
|
266
|
+
@property
|
|
267
|
+
def culling_margin(self) -> float:
|
|
268
|
+
return self._get_attr("cullingMargin", data_type="float", def_value=10.0)
|
|
269
|
+
|
|
270
|
+
@culling_margin.setter
|
|
271
|
+
def culling_margin(self, value: OptionalNumber):
|
|
272
|
+
self._set_attr("cullingMargin", value)
|
|
273
|
+
|
|
274
|
+
# simplification_tolerance
|
|
275
|
+
@property
|
|
276
|
+
def simplification_tolerance(self) -> float:
|
|
277
|
+
return self._get_attr(
|
|
278
|
+
"simplificationTolerance", data_type="float", def_value=0.4
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
@simplification_tolerance.setter
|
|
282
|
+
def simplification_tolerance(self, value: OptionalNumber):
|
|
283
|
+
self._set_attr("simplificationTolerance", value)
|
|
284
|
+
|
|
285
|
+
# min_hittable_radius
|
|
286
|
+
@property
|
|
287
|
+
def min_hittable_radius(self) -> float:
|
|
288
|
+
return self._get_attr("minHittableRadius", data_type="float", def_value=10.0)
|
|
289
|
+
|
|
290
|
+
@min_hittable_radius.setter
|
|
291
|
+
def min_hittable_radius(self, value: OptionalNumber):
|
|
292
|
+
self._set_attr("minHittableRadius", value)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from typing import Any, List, Optional
|
|
3
|
+
|
|
4
|
+
from flet.core.border_radius import BorderRadius
|
|
5
|
+
from flet.core.control import OptionalNumber
|
|
6
|
+
from flet_map.map_layer import MapLayer
|
|
7
|
+
from flet_map.text_source_attribution import TextSourceAttribution
|
|
8
|
+
from flet.core.ref import Ref
|
|
9
|
+
from flet.core.types import ColorEnums, ColorValue
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class AttributionAlignment(Enum):
|
|
13
|
+
BOTTOM_LEFT = "bottomLeft"
|
|
14
|
+
BOTTOM_RIGHT = "bottomRight"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class RichAttribution(MapLayer):
|
|
18
|
+
"""
|
|
19
|
+
An animated and interactive attribution layer that supports both logos/images and text
|
|
20
|
+
(displayed in a popup controlled by an icon button adjacent to the logos).
|
|
21
|
+
|
|
22
|
+
-----
|
|
23
|
+
|
|
24
|
+
Online docs: https://flet.dev/docs/controls/maprichattribution
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
def __init__(
|
|
28
|
+
self,
|
|
29
|
+
attributions: List[TextSourceAttribution],
|
|
30
|
+
alignment: Optional[AttributionAlignment] = None,
|
|
31
|
+
popup_bgcolor: Optional[ColorValue] = None,
|
|
32
|
+
popup_border_radius: Optional[BorderRadius] = None,
|
|
33
|
+
popup_initial_display_duration: Optional[int] = None,
|
|
34
|
+
permanent_height: OptionalNumber = None,
|
|
35
|
+
show_flutter_map_attribution: Optional[bool] = None,
|
|
36
|
+
#
|
|
37
|
+
# MapLayer
|
|
38
|
+
#
|
|
39
|
+
ref: Optional[Ref] = None,
|
|
40
|
+
visible: Optional[bool] = None,
|
|
41
|
+
data: Any = None,
|
|
42
|
+
):
|
|
43
|
+
|
|
44
|
+
MapLayer.__init__(
|
|
45
|
+
self,
|
|
46
|
+
ref=ref,
|
|
47
|
+
visible=visible,
|
|
48
|
+
data=data,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
self.attributions = attributions
|
|
52
|
+
self.alignment = alignment
|
|
53
|
+
self.popup_bgcolor = popup_bgcolor
|
|
54
|
+
self.permanent_height = permanent_height
|
|
55
|
+
self.show_flutter_map_attribution = show_flutter_map_attribution
|
|
56
|
+
self.popup_border_radius = popup_border_radius
|
|
57
|
+
self.popup_initial_display_duration = popup_initial_display_duration
|
|
58
|
+
|
|
59
|
+
def _get_control_name(self):
|
|
60
|
+
return "map_rich_attribution"
|
|
61
|
+
|
|
62
|
+
def _get_children(self):
|
|
63
|
+
return self.attributions
|
|
64
|
+
|
|
65
|
+
def before_update(self):
|
|
66
|
+
super().before_update()
|
|
67
|
+
self._set_attr_json("popupBorderRadius", self.__popup_border_radius)
|
|
68
|
+
self._set_attr_json("alignment", self.__alignment)
|
|
69
|
+
|
|
70
|
+
# permanent_height
|
|
71
|
+
@property
|
|
72
|
+
def permanent_height(self) -> float:
|
|
73
|
+
return self._get_attr("permanentHeight", data_type="float", def_value=24.0)
|
|
74
|
+
|
|
75
|
+
@permanent_height.setter
|
|
76
|
+
def permanent_height(self, value: OptionalNumber):
|
|
77
|
+
assert value is None or value >= 0, "permanent_height cannot be negative"
|
|
78
|
+
self._set_attr("permanentHeight", value)
|
|
79
|
+
|
|
80
|
+
# popup_initial_display_duration
|
|
81
|
+
@property
|
|
82
|
+
def popup_initial_display_duration(self) -> int:
|
|
83
|
+
return self._get_attr(
|
|
84
|
+
"popupInitialDisplayDuration", data_type="int", def_value=0
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
@popup_initial_display_duration.setter
|
|
88
|
+
def popup_initial_display_duration(self, value: Optional[int]):
|
|
89
|
+
assert (
|
|
90
|
+
value is None or value >= 0
|
|
91
|
+
), "popup_initial_display_duration cannot be negative"
|
|
92
|
+
self._set_attr("popupInitialDisplayDuration", value)
|
|
93
|
+
|
|
94
|
+
# popup_border_radius
|
|
95
|
+
@property
|
|
96
|
+
def popup_border_radius(self) -> Optional[BorderRadius]:
|
|
97
|
+
return self.__popup_border_radius
|
|
98
|
+
|
|
99
|
+
@popup_border_radius.setter
|
|
100
|
+
def popup_border_radius(self, value: Optional[BorderRadius]):
|
|
101
|
+
self.__popup_border_radius = value
|
|
102
|
+
|
|
103
|
+
# alignment
|
|
104
|
+
@property
|
|
105
|
+
def alignment(self) -> Optional[AttributionAlignment]:
|
|
106
|
+
return self.__alignment
|
|
107
|
+
|
|
108
|
+
@alignment.setter
|
|
109
|
+
def alignment(self, value: Optional[AttributionAlignment]):
|
|
110
|
+
self.__alignment = value
|
|
111
|
+
self._set_enum_attr("alignment", value, AttributionAlignment)
|
|
112
|
+
|
|
113
|
+
# show_flutter_map_attribution
|
|
114
|
+
@property
|
|
115
|
+
def show_flutter_map_attribution(self) -> bool:
|
|
116
|
+
return self._get_attr(
|
|
117
|
+
"showFlutterMapAttribution", data_type="bool", def_value=True
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
@show_flutter_map_attribution.setter
|
|
121
|
+
def show_flutter_map_attribution(self, value: Optional[bool]):
|
|
122
|
+
self._set_attr("showFlutterMapAttribution", value)
|
|
123
|
+
|
|
124
|
+
# popup_bgcolor
|
|
125
|
+
@property
|
|
126
|
+
def popup_bgcolor(self) -> Optional[str]:
|
|
127
|
+
return self.__popup_bgcolor
|
|
128
|
+
|
|
129
|
+
@popup_bgcolor.setter
|
|
130
|
+
def popup_bgcolor(self, value: Optional[str]):
|
|
131
|
+
self.__popup_bgcolor = value
|
|
132
|
+
self._set_enum_attr("popupBgcolor", value, ColorEnums)
|
|
133
|
+
|
|
134
|
+
# attributions
|
|
135
|
+
@property
|
|
136
|
+
def attributions(self) -> List[TextSourceAttribution]:
|
|
137
|
+
return self.__attributions
|
|
138
|
+
|
|
139
|
+
@attributions.setter
|
|
140
|
+
def attributions(self, value: List[TextSourceAttribution]):
|
|
141
|
+
self.__attributions = value
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
from flet.core.alignment import Alignment
|
|
4
|
+
from flet_map.map_layer import MapLayer
|
|
5
|
+
from flet.core.ref import Ref
|
|
6
|
+
from flet.core.types import ColorEnums, ColorValue, OptionalControlEventCallable
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class SimpleAttribution(MapLayer):
|
|
10
|
+
"""
|
|
11
|
+
A simple attribution layer displayed on the Map.
|
|
12
|
+
|
|
13
|
+
-----
|
|
14
|
+
|
|
15
|
+
Online docs: https://flet.dev/docs/controls/mapsimpleattribution
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
text: str,
|
|
21
|
+
alignment: Optional[Alignment] = None,
|
|
22
|
+
bgcolor: Optional[ColorValue] = None,
|
|
23
|
+
on_click: OptionalControlEventCallable = None,
|
|
24
|
+
#
|
|
25
|
+
# MapLayer
|
|
26
|
+
#
|
|
27
|
+
ref: Optional[Ref] = None,
|
|
28
|
+
visible: Optional[bool] = None,
|
|
29
|
+
data: Any = None,
|
|
30
|
+
):
|
|
31
|
+
|
|
32
|
+
MapLayer.__init__(
|
|
33
|
+
self,
|
|
34
|
+
ref=ref,
|
|
35
|
+
visible=visible,
|
|
36
|
+
data=data,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
self.text = text
|
|
40
|
+
self.alignment = alignment
|
|
41
|
+
self.bgcolor = bgcolor
|
|
42
|
+
self.on_click = on_click
|
|
43
|
+
|
|
44
|
+
def _get_control_name(self):
|
|
45
|
+
return "map_simple_attribution"
|
|
46
|
+
|
|
47
|
+
def before_update(self):
|
|
48
|
+
super().before_update()
|
|
49
|
+
self._set_attr_json("alignment", self.__alignment)
|
|
50
|
+
|
|
51
|
+
# alignment
|
|
52
|
+
@property
|
|
53
|
+
def alignment(self) -> Optional[Alignment]:
|
|
54
|
+
return self.__alignment
|
|
55
|
+
|
|
56
|
+
@alignment.setter
|
|
57
|
+
def alignment(self, value: Optional[Alignment]):
|
|
58
|
+
self.__alignment = value
|
|
59
|
+
|
|
60
|
+
# bgcolor
|
|
61
|
+
@property
|
|
62
|
+
def bgcolor(self) -> Optional[ColorValue]:
|
|
63
|
+
return self.__bgcolor
|
|
64
|
+
|
|
65
|
+
@bgcolor.setter
|
|
66
|
+
def bgcolor(self, value: Optional[ColorValue]):
|
|
67
|
+
self.__bgcolor = value
|
|
68
|
+
self._set_enum_attr("bgcolor", value, ColorEnums)
|
|
69
|
+
|
|
70
|
+
# text
|
|
71
|
+
@property
|
|
72
|
+
def text(self) -> str:
|
|
73
|
+
return self._get_attr("text")
|
|
74
|
+
|
|
75
|
+
@text.setter
|
|
76
|
+
def text(self, value: str):
|
|
77
|
+
self._set_attr("text", value)
|
|
78
|
+
|
|
79
|
+
# on_click
|
|
80
|
+
@property
|
|
81
|
+
def on_change(self) -> OptionalControlEventCallable:
|
|
82
|
+
return self._get_event_handler("click")
|
|
83
|
+
|
|
84
|
+
@on_change.setter
|
|
85
|
+
def on_change(self, handler: OptionalControlEventCallable):
|
|
86
|
+
self._add_event_handler("click", handler)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from typing import Any, Optional
|
|
2
|
+
|
|
3
|
+
from flet.core.control import Control
|
|
4
|
+
from flet.core.ref import Ref
|
|
5
|
+
from flet.core.text_style import TextStyle
|
|
6
|
+
from flet.core.types import OptionalControlEventCallable
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class TextSourceAttribution(Control):
|
|
10
|
+
"""
|
|
11
|
+
A text source attribution displayed on the Map.
|
|
12
|
+
For it to be displayed, it should be part of a RichAttribution.attributions list.
|
|
13
|
+
|
|
14
|
+
-----
|
|
15
|
+
|
|
16
|
+
Online docs: https://flet.dev/docs/controls/maptextsourceattribution
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(
|
|
20
|
+
self,
|
|
21
|
+
text: str,
|
|
22
|
+
text_style: Optional[TextStyle] = None,
|
|
23
|
+
prepend_copyright: Optional[bool] = None,
|
|
24
|
+
on_click: OptionalControlEventCallable = None,
|
|
25
|
+
#
|
|
26
|
+
# Control
|
|
27
|
+
#
|
|
28
|
+
ref: Optional[Ref] = None,
|
|
29
|
+
visible: Optional[bool] = None,
|
|
30
|
+
data: Any = None,
|
|
31
|
+
):
|
|
32
|
+
|
|
33
|
+
Control.__init__(
|
|
34
|
+
self,
|
|
35
|
+
ref=ref,
|
|
36
|
+
visible=visible,
|
|
37
|
+
data=data,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
self.text = text
|
|
41
|
+
self.text_style = text_style
|
|
42
|
+
self.prepend_copyright = prepend_copyright
|
|
43
|
+
self.on_click = on_click
|
|
44
|
+
|
|
45
|
+
def _get_control_name(self):
|
|
46
|
+
return "map_text_source_attribution"
|
|
47
|
+
|
|
48
|
+
def before_update(self):
|
|
49
|
+
super().before_update()
|
|
50
|
+
if isinstance(self.__text_style, TextStyle):
|
|
51
|
+
self._set_attr_json("textStyle", self.__text_style)
|
|
52
|
+
|
|
53
|
+
# text_style
|
|
54
|
+
@property
|
|
55
|
+
def text_style(self) -> Optional[TextStyle]:
|
|
56
|
+
return self.__text_style
|
|
57
|
+
|
|
58
|
+
@text_style.setter
|
|
59
|
+
def text_style(self, value: Optional[TextStyle]):
|
|
60
|
+
self.__text_style = value
|
|
61
|
+
|
|
62
|
+
# prepend_copyright
|
|
63
|
+
@property
|
|
64
|
+
def prepend_copyright(self) -> bool:
|
|
65
|
+
return self._get_attr("prependCopyright", data_type="bool", def_value=True)
|
|
66
|
+
|
|
67
|
+
@prepend_copyright.setter
|
|
68
|
+
def prepend_copyright(self, value: Optional[bool]):
|
|
69
|
+
self._set_attr("prependCopyright", value)
|
|
70
|
+
|
|
71
|
+
# text
|
|
72
|
+
@property
|
|
73
|
+
def text(self) -> str:
|
|
74
|
+
return self._get_attr("text")
|
|
75
|
+
|
|
76
|
+
@text.setter
|
|
77
|
+
def text(self, value: str):
|
|
78
|
+
self._set_attr("text", value)
|
|
79
|
+
|
|
80
|
+
# on_click
|
|
81
|
+
@property
|
|
82
|
+
def on_click(self) -> OptionalControlEventCallable:
|
|
83
|
+
return self._get_event_handler("click")
|
|
84
|
+
|
|
85
|
+
@on_click.setter
|
|
86
|
+
def on_click(self, handler: OptionalControlEventCallable):
|
|
87
|
+
self._add_event_handler("click", handler)
|