flet-map 0.70.0.dev6301__py3-none-any.whl → 0.70.0.dev6561__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/circle_layer.py CHANGED
@@ -12,9 +12,6 @@ class CircleMarker(ft.Control):
12
12
  """
13
13
  A circular marker displayed on the Map at the specified
14
14
  location through the [`CircleLayer`][(p).].
15
-
16
- Raises:
17
- AssertionError: If the [`border_stroke_width`][(c).] is negative.
18
15
  """
19
16
 
20
17
  radius: ft.Number
@@ -30,8 +27,8 @@ class CircleMarker(ft.Control):
30
27
  """
31
28
  The color of the circle border line.
32
29
 
33
- Note:
34
- [`border_stroke_width`][..] must to be greater than
30
+ Tip:
31
+ [`border_stroke_width`][(c).] must be greater than
35
32
  `0.0` in order for this color to be visible.
36
33
  """
37
34
 
@@ -39,21 +36,22 @@ class CircleMarker(ft.Control):
39
36
  """
40
37
  The stroke width for the circle border.
41
38
 
42
- Note:
43
- Must be non-negative.
39
+ Raises:
40
+ ValueError: If it is less than `0.0`.
44
41
  """
45
42
 
46
43
  use_radius_in_meter: bool = False
47
44
  """
48
- Whether the [`radius`][..] should use the unit meters.
45
+ Whether the [`radius`][(c).] should use the unit meters.
49
46
  """
50
47
 
51
48
  def before_update(self):
52
49
  super().before_update()
53
- assert self.border_stroke_width >= 0, (
54
- f"border_stroke_width must be greater than or equal to 0, "
55
- f"got {self.border_stroke_width}"
56
- )
50
+ if self.border_stroke_width < 0:
51
+ raise ValueError(
52
+ "border_stroke_width must be greater than or equal to 0, "
53
+ f"got {self.border_stroke_width}"
54
+ )
57
55
 
58
56
 
59
57
  @ft.control("CircleLayer")
flet_map/map.py CHANGED
@@ -100,7 +100,7 @@ class Map(ft.LayoutControl):
100
100
  initial_camera_fit: Optional[CameraFit] = None
101
101
  """
102
102
  Defines the visible bounds when the map is first loaded.
103
- Takes precedence over [`initial_center`][..]/[`initial_zoom`][..].
103
+ Takes precedence over [`initial_center`][(c).]/[`initial_zoom`][(c).].
104
104
  """
105
105
 
106
106
  on_init: Optional[ft.ControlEventHandler["Map"]] = None
@@ -244,7 +244,7 @@ class Map(ft.LayoutControl):
244
244
  Zooms out by one zoom-level from the current one.
245
245
 
246
246
  Args:
247
- animation_curve: The curve of the animation. If None (the default),
247
+ animation_curve: The curve of the animation. If `None` (the default),
248
248
  [`Map.animation_curve`][(p).] will be used.
249
249
  animation_duration: The duration of the animation.
250
250
  If None (the default), [`Map.animation_duration`][(p).] will be used.
@@ -272,7 +272,7 @@ class Map(ft.LayoutControl):
272
272
 
273
273
  Args:
274
274
  zoom: The zoom level to zoom to.
275
- animation_curve: The curve of the animation. If None (the default),
275
+ animation_curve: The curve of the animation. If `None` (the default),
276
276
  [`Map.animation_curve`][(p).] will be used.
277
277
  animation_duration: The duration of the animation.
278
278
  If None (the default), [`Map.animation_duration`][(p).] will be used.
@@ -316,11 +316,10 @@ class Map(ft.LayoutControl):
316
316
  ongoing map-animations before starting this new one.
317
317
 
318
318
  Raises:
319
- AssertionError: If `zoom` is not `None` and is negative.
319
+ ValueError: If `zoom` is not `None` and is negative.
320
320
  """
321
- assert zoom is None or zoom >= 0, (
322
- f"zoom must be greater than or equal to zero, got {zoom}"
323
- )
321
+ if zoom is not None and zoom < 0:
322
+ raise ValueError(f"zoom must be greater than or equal to zero, got {zoom}")
324
323
  await self._invoke_method(
325
324
  method_name="move_to",
326
325
  arguments={
flet_map/marker_layer.py CHANGED
@@ -13,18 +13,14 @@ class Marker(ft.Control):
13
13
  """
14
14
  A marker displayed on the Map at the specified location
15
15
  through the [`MarkerLayer`][(p).].
16
-
17
- Raises:
18
- AssertionError: If the [`content`][(c).] is not visible, or
19
- if [`height`][(c).] or [`width`][(c).] are negative.
20
16
  """
21
17
 
22
18
  content: ft.Control
23
19
  """
24
- The content to be displayed at [`coordinates`][..].
20
+ The content to be displayed at [`coordinates`][(c).].
25
21
 
26
- Note:
27
- Must be provided and visible.
22
+ Raises:
23
+ ValueError: If it is not [`visible`][(c).].
28
24
  """
29
25
 
30
26
  coordinates: MapLatitudeLongitude
@@ -32,7 +28,7 @@ class Marker(ft.Control):
32
28
  The coordinates of the marker.
33
29
 
34
30
  This will be the center of the marker,
35
- if [`alignment`][..] is [`Alignment.CENTER`][flet.Alignment.CENTER].
31
+ if [`alignment`][(c).] is [`Alignment.CENTER`][flet.].
36
32
  """
37
33
 
38
34
  rotate: Optional[bool] = None
@@ -51,36 +47,39 @@ class Marker(ft.Control):
51
47
 
52
48
  height: ft.Number = 30.0
53
49
  """
54
- The height of the [`content`][..] Control.
50
+ The height of the [`content`][(c).] Control.
55
51
 
56
- Note:
57
- Must be non-negative.
52
+ Raises:
53
+ ValueError: If it is less than `0.0`.
58
54
  """
59
55
 
60
56
  width: ft.Number = 30.0
61
57
  """
62
- The width of the [`content`][..] Control.
58
+ The width of the [`content`][(c).] Control.
63
59
 
64
- Note:
65
- Must be non-negative.
60
+ Raises:
61
+ ValueError: If it is less than `0.0`.
66
62
  """
67
63
 
68
64
  alignment: Optional[ft.Alignment] = None
69
65
  """
70
- Alignment of the marker relative to the normal center at [`coordinates`][..].
66
+ Alignment of the marker relative to the normal center at [`coordinates`][(c).].
71
67
 
72
68
  Defaults to the value of the parent [`MarkerLayer.alignment`][(p).].
73
69
  """
74
70
 
75
71
  def before_update(self):
76
72
  super().before_update()
77
- assert self.content.visible, "content must be visible"
78
- assert self.height >= 0, (
79
- f"height must be greater than or equal to 0, got {self.height}"
80
- )
81
- assert self.width >= 0, (
82
- f"width must be greater than or equal to 0, got {self.width}"
83
- )
73
+ if not self.content.visible:
74
+ raise ValueError("content must be visible")
75
+ if self.height < 0:
76
+ raise ValueError(
77
+ f"height must be greater than or equal to 0, got {self.height}"
78
+ )
79
+ if self.width < 0:
80
+ raise ValueError(
81
+ f"width must be greater than or equal to 0, got {self.width}"
82
+ )
84
83
 
85
84
 
86
85
  @ft.control("MarkerLayer")
@@ -91,7 +90,7 @@ class MarkerLayer(MapLayer):
91
90
 
92
91
  markers: list[Marker]
93
92
  """
94
- A list of [`Marker`][(m).]s to display.
93
+ A list of [`Marker`][(p).]s to display.
95
94
  """
96
95
 
97
96
  alignment: Optional[ft.Alignment] = field(
@@ -99,11 +98,11 @@ class MarkerLayer(MapLayer):
99
98
  )
100
99
  """
101
100
  The alignment of each marker relative to its normal center at
102
- [`Marker.coordinates`][(m).].
101
+ [`Marker.coordinates`][(p).].
103
102
  """
104
103
 
105
104
  rotate: bool = False
106
105
  """
107
- Whether to counter-rotate `markers` to the map's rotation,
106
+ Whether to counter-rotate [`markers`][(c).] to the map's rotation,
108
107
  to keep a fixed orientation.
109
108
  """
flet_map/polygon_layer.py CHANGED
@@ -22,10 +22,11 @@ class PolygonMarker(ft.Control):
22
22
  """
23
23
  An optional label for this polygon.
24
24
 
25
- Note: specifying a label will reduce performance, as the internal
26
- canvas must be drawn to and 'saved' more frequently to ensure the proper
27
- stacking order is maintained. This can be avoided, potentially at the
28
- expense of appearance, by setting [`PolygonLayer.draw_labels_last`][(p).].
25
+ Note:
26
+ Specifying a label will reduce performance, as the internal
27
+ canvas must be drawn to and 'saved' more frequently to ensure the proper
28
+ stacking order is maintained. This can be avoided, potentially at the
29
+ expense of appearance, by setting [`PolygonLayer.draw_labels_last`][(p).].
29
30
  """
30
31
 
31
32
  label_text_style: Optional[ft.TextStyle] = None
@@ -47,8 +48,8 @@ class PolygonMarker(ft.Control):
47
48
  """
48
49
  The width of the border outline.
49
50
 
50
- Note:
51
- Must be non-negative.
51
+ Raises:
52
+ ValueError: If it is less than `0.0`.
52
53
  """
53
54
 
54
55
  disable_holes_border: bool = False
@@ -74,10 +75,11 @@ class PolygonMarker(ft.Control):
74
75
 
75
76
  def before_update(self):
76
77
  super().before_update()
77
- assert self.border_stroke_width >= 0, (
78
- f"border_stroke_width must be greater than or equal to 0, "
79
- f"got {self.border_stroke_width}"
80
- )
78
+ if self.border_stroke_width < 0:
79
+ raise ValueError(
80
+ "border_stroke_width must be greater than or equal to 0, "
81
+ f"got {self.border_stroke_width}"
82
+ )
81
83
 
82
84
 
83
85
  @ft.control("PolygonLayer")
@@ -21,7 +21,7 @@ class PolylineMarker(ft.Control):
21
21
 
22
22
  colors_stop: Optional[list[ft.Number]] = None
23
23
  """
24
- The stops for the [`gradient_colors`][..].
24
+ The stops for the [`gradient_colors`][(c).].
25
25
  """
26
26
 
27
27
  gradient_colors: Optional[list[ft.ColorValue]] = None
@@ -43,16 +43,16 @@ class PolylineMarker(ft.Control):
43
43
  """
44
44
  The width of the stroke.
45
45
 
46
- Note:
47
- Must be non-negative.
46
+ Raises:
47
+ ValueError: If it is less than `0.0`.
48
48
  """
49
49
 
50
50
  border_stroke_width: ft.Number = 0.0
51
51
  """
52
52
  The width of the stroke with of the line border.
53
53
 
54
- Note:
55
- Must be non-negative.
54
+ Raises:
55
+ ValueError: If it is less than `0.0`.
56
56
  """
57
57
 
58
58
  use_stroke_width_in_meter: bool = False
@@ -78,13 +78,16 @@ class PolylineMarker(ft.Control):
78
78
 
79
79
  def before_update(self):
80
80
  super().before_update()
81
- assert self.border_stroke_width >= 0, (
82
- f"border_stroke_width must be greater than or equal to 0, "
83
- f"got {self.border_stroke_width}"
84
- )
85
- assert self.stroke_width >= 0, (
86
- f"stroke_width must be greater than or equal to 0, got {self.stroke_width}"
87
- )
81
+ if self.border_stroke_width < 0:
82
+ raise ValueError(
83
+ "border_stroke_width must be greater than or equal to 0, "
84
+ f"got {self.border_stroke_width}"
85
+ )
86
+ if self.stroke_width < 0:
87
+ raise ValueError(
88
+ f"stroke_width must be greater than or equal to 0, "
89
+ f"got {self.stroke_width}"
90
+ )
88
91
 
89
92
 
90
93
  @ft.control("PolylineLayer")
@@ -25,7 +25,7 @@ class SimpleAttribution(MapLayer):
25
25
 
26
26
  bgcolor: ft.ColorValue = ft.Colors.SURFACE
27
27
  """
28
- The color of the box containing the [`text`][..].
28
+ The color of the box containing the [`text`][(c).].
29
29
  """
30
30
 
31
31
  on_click: Optional[ft.ControlEventHandler["SimpleAttribution"]] = None
@@ -23,17 +23,14 @@ class ImageSourceAttribution(SourceAttribution):
23
23
  open/close icon of a [`RichAttribution`][(p).] control.
24
24
  For it to be displayed, it should be part of a
25
25
  [`RichAttribution.attributions`][(p).] list.
26
-
27
- Raises:
28
- AssertionError: If the [`image`][(c).] is not visible.
29
26
  """
30
27
 
31
28
  image: ft.Image
32
29
  """
33
- The `Image` to be displayed.
30
+ The [`Image`][flet.] to be displayed.
34
31
 
35
- Note:
36
- Must be provided and visible.
32
+ Raises:
33
+ ValueError: If the image is not visible.
37
34
  """
38
35
 
39
36
  height: ft.Number = 24.0
@@ -51,7 +48,8 @@ class ImageSourceAttribution(SourceAttribution):
51
48
 
52
49
  def before_update(self):
53
50
  super().before_update()
54
- assert self.image.visible, "image must be visible"
51
+ if not self.image.visible:
52
+ raise ValueError("image must be visible")
55
53
 
56
54
 
57
55
  @ft.control("TextSourceAttribution")
@@ -63,14 +61,14 @@ class TextSourceAttribution(SourceAttribution):
63
61
  """
64
62
 
65
63
  text: str
66
- """The text to display as attribution, styled with [`text_style`][..]."""
64
+ """The text to display as attribution, styled with [`text_style`][(c).]."""
67
65
 
68
66
  text_style: Optional[ft.TextStyle] = None
69
- """Style used to display the [`text`][..]."""
67
+ """Style used to display the [`text`][(c).]."""
70
68
 
71
69
  prepend_copyright: bool = True
72
70
  """
73
- Whether to add the '©' character to the start of [`text`][..] automatically.
71
+ Whether to add the '©' character to the start of [`text`][(c).] automatically.
74
72
  """
75
73
 
76
74
  on_click: Optional[ft.ControlEventHandler["TextSourceAttribution"]] = None
flet_map/tile_layer.py CHANGED
@@ -22,12 +22,6 @@ class TileLayer(MapLayer):
22
22
  Typically the first layer to be added to a [`Map`][(p).],
23
23
  as it provides the tiles on which
24
24
  other layers are displayed.
25
-
26
- Raises:
27
- AssertionError: If one or more of the following is negative:
28
- [`tile_size`][(c).], [`min_native_zoom`][(c).],
29
- [`max_native_zoom`][(c).], [`zoom_offset`][(c).],
30
- [`max_zoom`][(c).], [`min_zoom`][(c).]
31
25
  """
32
26
 
33
27
  url_template: str
@@ -39,21 +33,21 @@ class TileLayer(MapLayer):
39
33
  fallback_url: Optional[str] = None
40
34
  """
41
35
  Fallback URL template, used if an error occurs when fetching tiles from
42
- the [`url_template`][..].
36
+ the [`url_template`][(c).].
43
37
 
44
38
  Note that specifying this (non-none) will result in tiles not being cached
45
- in memory. This is to avoid issues where the [`url_template`][..] is flaky, to
39
+ in memory. This is to avoid issues where the [`url_template`][(c).] is flaky, to
46
40
  prevent different tilesets being displayed at the same time.
47
41
 
48
42
  It is expected that this follows the same retina support behaviour
49
- as [`url_template`][..].
43
+ as [`url_template`][(c).].
50
44
  """
51
45
 
52
46
  subdomains: list[str] = field(default_factory=lambda: ["a", "b", "c"])
53
47
  """
54
48
  List of subdomains used in the URL template.
55
49
 
56
- For example, if [`subdomains`][..] is set to `["a", "b", "c"]` and the
50
+ For example, if [`subdomains`][(c).] is set to `["a", "b", "c"]` and the
57
51
  `url_template` is `"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"`,
58
52
  the resulting tile URLs will be:
59
53
 
@@ -73,8 +67,8 @@ class TileLayer(MapLayer):
73
67
  The size in pixels of each tile image.
74
68
  Should be a positive power of 2.
75
69
 
76
- Note:
77
- Must be greater than or equal to `0.0`.
70
+ Raises:
71
+ ValueError: If it is less than `0.0`.
78
72
  """
79
73
 
80
74
  min_native_zoom: int = 0
@@ -87,8 +81,8 @@ class TileLayer(MapLayer):
87
81
  This should usually be 0 (as default), as most tile sources will support
88
82
  zoom levels onwards from this.
89
83
 
90
- Note:
91
- Must be greater than or equal to `0.0`.
84
+ Raises:
85
+ ValueError: If it is less than `0.0`.
92
86
  """
93
87
 
94
88
  max_native_zoom: int = 19
@@ -101,8 +95,8 @@ class TileLayer(MapLayer):
101
95
  Most tile servers support up to zoom level `19`, which is the default.
102
96
  Otherwise, this should be specified.
103
97
 
104
- Note:
105
- Must be greater than or equal to `0.0`.
98
+ Raises:
99
+ ValueError: If it is less than `0.0`.
106
100
  """
107
101
 
108
102
  zoom_reverse: bool = False
@@ -115,8 +109,8 @@ class TileLayer(MapLayer):
115
109
  """
116
110
  The zoom number used in tile URLs will be offset with this value.
117
111
 
118
- Note:
119
- Must be greater than or equal to `0.0`.
112
+ Raises:
113
+ ValueError: If it is less than `0.0`.
120
114
  """
121
115
 
122
116
  keep_buffer: int = 2
@@ -148,7 +142,7 @@ class TileLayer(MapLayer):
148
142
 
149
143
  additional_options: dict[str, str] = field(default_factory=dict)
150
144
  """
151
- Static information that should replace placeholders in the [`url_template`][..].
145
+ Static information that should replace placeholders in the [`url_template`][(c).].
152
146
  Applying API keys, for example, is a good usecase of this parameter.
153
147
 
154
148
  Example:
@@ -159,7 +153,7 @@ class TileLayer(MapLayer):
159
153
  'accessToken': '<ACCESS_TOKEN_HERE>',
160
154
  'id': 'mapbox.streets',
161
155
  },
162
- ),
156
+ )
163
157
  ```
164
158
  """
165
159
 
@@ -169,29 +163,30 @@ class TileLayer(MapLayer):
169
163
  The main usage for this property is to display a different `TileLayer`
170
164
  when zoomed far in.
171
165
 
172
- Prefer [`max_native_zoom`][..] for setting the maximum zoom level supported by the
166
+ Prefer [`max_native_zoom`][(c).] for setting the maximum zoom level supported by the
173
167
  tile source.
174
168
 
175
169
  Typically set to infinity so that there are tiles always displayed.
176
170
 
177
- Note:
178
- Must be greater than or equal to `0.0`.
171
+ Raises:
172
+ ValueError: If it is less than `0.0`.
179
173
  """
180
174
 
181
175
  min_zoom: ft.Number = 0.0
182
176
  """
183
177
  The minimum zoom level at which this layer is displayed (inclusive).
178
+
184
179
  Typically `0.0`.
185
180
 
186
- Note:
187
- Must be greater than or equal to `0.0`.
181
+ Raises:
182
+ ValueError: If it is less than `0.0`.
188
183
  """
189
184
 
190
185
  error_image_src: Optional[str] = None
191
186
  """
192
187
  The source of the tile image to show in place of the tile that failed to load.
193
188
 
194
- See [`on_image_error`][..] property for details on the error.
189
+ See [`on_image_error`][(c).] property for details on the error.
195
190
  """
196
191
 
197
192
  evict_error_tile_strategy: Optional[TileLayerEvictErrorTileStrategy] = (
@@ -217,29 +212,36 @@ class TileLayer(MapLayer):
217
212
  """
218
213
  Fires if an error occurs when fetching the tiles.
219
214
 
220
- Event handler argument [`data`][flet.Event.data] property contains
215
+ Event handler argument [`data`][flet.Event.] property contains
221
216
  information about the error.
222
217
  """
223
218
 
224
219
  def before_update(self):
225
220
  super().before_update()
226
- assert self.tile_size >= 0, (
227
- f"tile_size must be greater than or equal to 0, got {self.tile_size}"
228
- )
229
- assert self.min_native_zoom >= 0, (
230
- f"min_native_zoom must be greater than or equal to 0, "
231
- f"got {self.min_native_zoom}"
232
- )
233
- assert self.max_native_zoom >= 0, (
234
- f"max_native_zoom must be greater than or equal to 0, "
235
- f"got {self.max_native_zoom}"
236
- )
237
- assert self.zoom_offset >= 0, (
238
- f"zoom_offset must be greater than or equal to 0, got {self.zoom_offset}"
239
- )
240
- assert self.max_zoom >= 0, (
241
- f"max_zoom must be greater than or equal to 0, got {self.max_zoom}"
242
- )
243
- assert self.min_zoom >= 0, (
244
- f"min_zoom must be greater than or equal to 0, got {self.min_zoom}"
245
- )
221
+ if self.tile_size < 0:
222
+ raise ValueError(
223
+ f"tile_size must be greater than or equal to 0, got {self.tile_size}"
224
+ )
225
+ if self.min_native_zoom < 0:
226
+ raise ValueError(
227
+ "min_native_zoom must be greater than or equal to 0, "
228
+ f"got {self.min_native_zoom}"
229
+ )
230
+ if self.max_native_zoom < 0:
231
+ raise ValueError(
232
+ "max_native_zoom must be greater than or equal to 0, "
233
+ f"got {self.max_native_zoom}"
234
+ )
235
+ if self.zoom_offset < 0:
236
+ raise ValueError(
237
+ f"zoom_offset must be greater than or equal to 0, "
238
+ f"got {self.zoom_offset}"
239
+ )
240
+ if self.max_zoom < 0:
241
+ raise ValueError(
242
+ f"max_zoom must be greater than or equal to 0, got {self.max_zoom}"
243
+ )
244
+ if self.min_zoom < 0:
245
+ raise ValueError(
246
+ f"min_zoom must be greater than or equal to 0, got {self.min_zoom}"
247
+ )