flet-map 0.2.0.dev46__py3-none-any.whl → 0.2.0.dev58__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 +44 -0
- flet_map/circle_layer.py +15 -11
- flet_map/map.py +146 -106
- flet_map/marker_layer.py +36 -23
- flet_map/polygon_layer.py +13 -12
- flet_map/polyline_layer.py +13 -10
- flet_map/rich_attribution.py +11 -8
- flet_map/simple_attribution.py +4 -6
- flet_map/source_attribution.py +12 -8
- flet_map/tile_layer.py +46 -37
- flet_map/types.py +218 -155
- {flet_map-0.2.0.dev46.dist-info → flet_map-0.2.0.dev58.dist-info}/METADATA +1 -1
- {flet_map-0.2.0.dev46.dist-info → flet_map-0.2.0.dev58.dist-info}/RECORD +18 -18
- flutter/flet_map/pubspec.lock +11 -11
- flutter/flet_map/pubspec.yaml +1 -1
- {flet_map-0.2.0.dev46.dist-info → flet_map-0.2.0.dev58.dist-info}/WHEEL +0 -0
- {flet_map-0.2.0.dev46.dist-info → flet_map-0.2.0.dev58.dist-info}/licenses/LICENSE +0 -0
- {flet_map-0.2.0.dev46.dist-info → flet_map-0.2.0.dev58.dist-info}/top_level.txt +0 -0
flet_map/marker_layer.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import field
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Optional
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
5
|
|
|
@@ -12,16 +12,18 @@ __all__ = ["Marker", "MarkerLayer"]
|
|
|
12
12
|
@ft.control("Marker")
|
|
13
13
|
class Marker(ft.Control):
|
|
14
14
|
"""
|
|
15
|
-
A marker displayed on the Map at the specified location
|
|
15
|
+
A marker displayed on the Map at the specified location
|
|
16
|
+
through the [`MarkerLayer`][(p).].
|
|
16
17
|
|
|
17
18
|
Raises:
|
|
18
|
-
AssertionError: If the [`content`][(c).] is not visible, or
|
|
19
|
+
AssertionError: If the [`content`][(c).] is not visible, or
|
|
20
|
+
if [`height`][(c).] or [`width`][(c).] are negative.
|
|
19
21
|
"""
|
|
20
22
|
|
|
21
23
|
content: ft.Control
|
|
22
24
|
"""
|
|
23
25
|
The content to be displayed at [`coordinates`][..].
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
Note:
|
|
26
28
|
Must be provided and visible.
|
|
27
29
|
"""
|
|
@@ -29,24 +31,29 @@ class Marker(ft.Control):
|
|
|
29
31
|
coordinates: MapLatitudeLongitude
|
|
30
32
|
"""
|
|
31
33
|
The coordinates of the marker.
|
|
32
|
-
|
|
33
|
-
This will be the center of the marker,
|
|
34
|
+
|
|
35
|
+
This will be the center of the marker,
|
|
36
|
+
if [`alignment`][..] is [`Alignment.CENTER`][flet.Alignment.CENTER].
|
|
34
37
|
"""
|
|
35
38
|
|
|
36
39
|
rotate: Optional[bool] = None
|
|
37
40
|
"""
|
|
38
|
-
Whether to counter rotate this marker to the map's rotation,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
Whether to counter rotate this marker to the map's rotation,
|
|
42
|
+
to keep a fixed orientation.
|
|
43
|
+
So, when `True`, this marker will always appear upright and
|
|
44
|
+
vertical from the user's perspective.
|
|
45
|
+
|
|
46
|
+
If `None`, defaults to the value of the parent [`MarkerLayer.rotate`][(p).].
|
|
47
|
+
|
|
48
|
+
Note:
|
|
49
|
+
This is not used to apply a custom rotation in degrees to this marker.
|
|
50
|
+
|
|
44
51
|
"""
|
|
45
52
|
|
|
46
53
|
height: ft.Number = 30.0
|
|
47
54
|
"""
|
|
48
55
|
The height of the [`content`][..] Control.
|
|
49
|
-
|
|
56
|
+
|
|
50
57
|
Note:
|
|
51
58
|
Must be non-negative.
|
|
52
59
|
"""
|
|
@@ -54,7 +61,7 @@ class Marker(ft.Control):
|
|
|
54
61
|
width: ft.Number = 30.0
|
|
55
62
|
"""
|
|
56
63
|
The width of the [`content`][..] Control.
|
|
57
|
-
|
|
64
|
+
|
|
58
65
|
Note:
|
|
59
66
|
Must be non-negative.
|
|
60
67
|
"""
|
|
@@ -62,15 +69,19 @@ class Marker(ft.Control):
|
|
|
62
69
|
alignment: Optional[ft.Alignment] = None
|
|
63
70
|
"""
|
|
64
71
|
Alignment of the marker relative to the normal center at [`coordinates`][..].
|
|
65
|
-
|
|
66
|
-
Defaults to the value of the parent [`MarkerLayer.alignment`][(
|
|
72
|
+
|
|
73
|
+
Defaults to the value of the parent [`MarkerLayer.alignment`][(p).].
|
|
67
74
|
"""
|
|
68
75
|
|
|
69
76
|
def before_update(self):
|
|
70
77
|
super().before_update()
|
|
71
78
|
assert self.content.visible, "content must be visible"
|
|
72
|
-
assert self.height >= 0,
|
|
73
|
-
|
|
79
|
+
assert self.height >= 0, (
|
|
80
|
+
f"height must be greater than or equal to 0, got {self.height}"
|
|
81
|
+
)
|
|
82
|
+
assert self.width >= 0, (
|
|
83
|
+
f"width must be greater than or equal to 0, got {self.width}"
|
|
84
|
+
)
|
|
74
85
|
|
|
75
86
|
|
|
76
87
|
@ft.control("MarkerLayer")
|
|
@@ -79,19 +90,21 @@ class MarkerLayer(MapLayer):
|
|
|
79
90
|
A layer to display Markers.
|
|
80
91
|
"""
|
|
81
92
|
|
|
82
|
-
markers:
|
|
93
|
+
markers: list[Marker]
|
|
83
94
|
"""
|
|
84
|
-
|
|
95
|
+
A list of [`Marker`][(m).]s to display.
|
|
85
96
|
"""
|
|
86
97
|
|
|
87
98
|
alignment: Optional[ft.Alignment] = field(
|
|
88
|
-
default_factory=lambda: ft.Alignment.
|
|
99
|
+
default_factory=lambda: ft.Alignment.CENTER
|
|
89
100
|
)
|
|
90
101
|
"""
|
|
91
|
-
|
|
102
|
+
The alignment of each marker relative to its normal center at
|
|
103
|
+
[`Marker.coordinates`][(m).].
|
|
92
104
|
"""
|
|
93
105
|
|
|
94
106
|
rotate: bool = False
|
|
95
107
|
"""
|
|
96
|
-
Whether to counter-rotate `markers` to the map's rotation,
|
|
108
|
+
Whether to counter-rotate `markers` to the map's rotation,
|
|
109
|
+
to keep a fixed orientation.
|
|
97
110
|
"""
|
flet_map/polygon_layer.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
from typing import
|
|
1
|
+
from typing import Optional
|
|
2
2
|
|
|
3
3
|
import flet as ft
|
|
4
4
|
|
|
5
5
|
from .map_layer import MapLayer
|
|
6
6
|
from .types import MapLatitudeLongitude
|
|
7
7
|
|
|
8
|
-
__all__ = ["
|
|
8
|
+
__all__ = ["PolygonLayer", "PolygonMarker"]
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@ft.control("PolygonMarker")
|
|
@@ -14,7 +14,7 @@ class PolygonMarker(ft.Control):
|
|
|
14
14
|
A marker for the [`PolygonLayer`][(p).].
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
-
coordinates:
|
|
17
|
+
coordinates: list[MapLatitudeLongitude]
|
|
18
18
|
"""
|
|
19
19
|
The points for the outline of this polygon.
|
|
20
20
|
"""
|
|
@@ -47,7 +47,7 @@ class PolygonMarker(ft.Control):
|
|
|
47
47
|
border_stroke_width: ft.Number = 0.0
|
|
48
48
|
"""
|
|
49
49
|
The width of the border outline.
|
|
50
|
-
|
|
50
|
+
|
|
51
51
|
Note:
|
|
52
52
|
Must be non-negative.
|
|
53
53
|
"""
|
|
@@ -59,7 +59,7 @@ class PolygonMarker(ft.Control):
|
|
|
59
59
|
|
|
60
60
|
rotate_label: bool = False
|
|
61
61
|
"""
|
|
62
|
-
Whether to rotate the label counter to the camera's rotation,
|
|
62
|
+
Whether to rotate the label counter to the camera's rotation,
|
|
63
63
|
to ensure it remains upright.
|
|
64
64
|
"""
|
|
65
65
|
|
|
@@ -75,9 +75,10 @@ class PolygonMarker(ft.Control):
|
|
|
75
75
|
|
|
76
76
|
def before_update(self):
|
|
77
77
|
super().before_update()
|
|
78
|
-
assert (
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
assert self.border_stroke_width >= 0, (
|
|
79
|
+
f"border_stroke_width must be greater than or equal to 0, "
|
|
80
|
+
f"got {self.border_stroke_width}"
|
|
81
|
+
)
|
|
81
82
|
|
|
82
83
|
|
|
83
84
|
@ft.control("PolygonLayer")
|
|
@@ -86,7 +87,7 @@ class PolygonLayer(MapLayer):
|
|
|
86
87
|
A layer to display PolygonMarkers.
|
|
87
88
|
"""
|
|
88
89
|
|
|
89
|
-
polygons:
|
|
90
|
+
polygons: list[PolygonMarker]
|
|
90
91
|
"""
|
|
91
92
|
A list of [`PolygonMarker`][(p).]s to display.
|
|
92
93
|
"""
|
|
@@ -108,14 +109,14 @@ class PolygonLayer(MapLayer):
|
|
|
108
109
|
|
|
109
110
|
simplification_tolerance: ft.Number = 0.3
|
|
110
111
|
"""
|
|
111
|
-
|
|
112
|
+
|
|
112
113
|
"""
|
|
113
114
|
|
|
114
115
|
use_alternative_rendering: bool = False
|
|
115
116
|
"""
|
|
116
117
|
Whether to use an alternative rendering pathway to draw polygons onto the
|
|
117
|
-
underlying `Canvas`, which can be more performant in 'some' circumstances.
|
|
118
|
-
|
|
118
|
+
underlying `Canvas`, which can be more performant in 'some' circumstances.
|
|
119
|
+
|
|
119
120
|
This will not always improve performance, and there are other important
|
|
120
121
|
considerations before enabling it. It is intended for use when prior
|
|
121
122
|
profiling indicates more performance is required after other methods are
|
flet_map/polyline_layer.py
CHANGED
|
@@ -6,7 +6,7 @@ import flet as ft
|
|
|
6
6
|
from .map_layer import MapLayer
|
|
7
7
|
from .types import MapLatitudeLongitude, SolidStrokePattern, StrokePattern
|
|
8
8
|
|
|
9
|
-
__all__ = ["
|
|
9
|
+
__all__ = ["PolylineLayer", "PolylineMarker"]
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
@ft.control("PolylineMarker")
|
|
@@ -43,7 +43,7 @@ class PolylineMarker(ft.Control):
|
|
|
43
43
|
stroke_width: ft.Number = 1.0
|
|
44
44
|
"""
|
|
45
45
|
The width of the stroke.
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
Note:
|
|
48
48
|
Must be non-negative.
|
|
49
49
|
"""
|
|
@@ -51,7 +51,7 @@ class PolylineMarker(ft.Control):
|
|
|
51
51
|
border_stroke_width: ft.Number = 0.0
|
|
52
52
|
"""
|
|
53
53
|
The width of the stroke with of the line border.
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
Note:
|
|
56
56
|
Must be non-negative.
|
|
57
57
|
"""
|
|
@@ -79,10 +79,13 @@ class PolylineMarker(ft.Control):
|
|
|
79
79
|
|
|
80
80
|
def before_update(self):
|
|
81
81
|
super().before_update()
|
|
82
|
-
assert (
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
assert self.border_stroke_width >= 0, (
|
|
83
|
+
f"border_stroke_width must be greater than or equal to 0, "
|
|
84
|
+
f"got {self.border_stroke_width}"
|
|
85
|
+
)
|
|
86
|
+
assert self.stroke_width >= 0, (
|
|
87
|
+
f"stroke_width must be greater than or equal to 0, got {self.stroke_width}"
|
|
88
|
+
)
|
|
86
89
|
|
|
87
90
|
|
|
88
91
|
@ft.control("PolylineLayer")
|
|
@@ -93,7 +96,7 @@ class PolylineLayer(MapLayer):
|
|
|
93
96
|
|
|
94
97
|
polylines: list[PolylineMarker]
|
|
95
98
|
"""
|
|
96
|
-
List of [`PolylineMarker`][(p).]s to be drawn.
|
|
99
|
+
List of [`PolylineMarker`][(p).]s to be drawn.
|
|
97
100
|
"""
|
|
98
101
|
|
|
99
102
|
culling_margin: ft.Number = 10.0
|
|
@@ -104,12 +107,12 @@ class PolylineLayer(MapLayer):
|
|
|
104
107
|
min_hittable_radius: ft.Number = 10.0
|
|
105
108
|
"""
|
|
106
109
|
The minimum radius of the hittable area around each polyline in logical pixels.
|
|
107
|
-
|
|
110
|
+
|
|
108
111
|
The entire visible area is always hittable, but if the visible area is
|
|
109
112
|
smaller than this, then this will be the hittable area.
|
|
110
113
|
"""
|
|
111
114
|
|
|
112
115
|
simplification_tolerance: ft.Number = 0.3
|
|
113
116
|
"""
|
|
114
|
-
|
|
117
|
+
|
|
115
118
|
"""
|
flet_map/rich_attribution.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import field
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Optional
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
5
|
|
|
@@ -17,11 +17,11 @@ class RichAttribution(MapLayer):
|
|
|
17
17
|
(displayed in a popup controlled by an icon button adjacent to the images).
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
-
attributions:
|
|
20
|
+
attributions: list[SourceAttribution]
|
|
21
21
|
"""
|
|
22
22
|
List of attributions to display.
|
|
23
|
-
|
|
24
|
-
[`TextSourceAttribution`][(p).]s are shown in a popup box,
|
|
23
|
+
|
|
24
|
+
[`TextSourceAttribution`][(p).]s are shown in a popup box,
|
|
25
25
|
unlike [`ImageSourceAttribution`][(p).], which are visible permanently.
|
|
26
26
|
"""
|
|
27
27
|
|
|
@@ -44,10 +44,12 @@ class RichAttribution(MapLayer):
|
|
|
44
44
|
default_factory=lambda: ft.Duration()
|
|
45
45
|
)
|
|
46
46
|
"""
|
|
47
|
-
The popup box will be open by default and be hidden this
|
|
48
|
-
|
|
47
|
+
The popup box will be open by default and be hidden this
|
|
48
|
+
long after the map is initialised.
|
|
49
|
+
|
|
49
50
|
This is useful with certain sources/tile servers that make immediate
|
|
50
|
-
attribution mandatory and are not attributed with a permanently
|
|
51
|
+
attribution mandatory and are not attributed with a permanently
|
|
52
|
+
visible [`ImageSourceAttribution`][(p).].
|
|
51
53
|
"""
|
|
52
54
|
|
|
53
55
|
permanent_height: ft.Number = 24.0
|
|
@@ -58,6 +60,7 @@ class RichAttribution(MapLayer):
|
|
|
58
60
|
|
|
59
61
|
show_flutter_map_attribution: bool = True
|
|
60
62
|
"""
|
|
61
|
-
Whether to add an additional attribution logo and text
|
|
63
|
+
Whether to add an additional attribution logo and text
|
|
64
|
+
for [`flutter-map`](https://docs.fleaflet.dev/),
|
|
62
65
|
on which 'flet-map' package is based for map-renderings.
|
|
63
66
|
"""
|
flet_map/simple_attribution.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import field
|
|
2
|
-
from typing import Union
|
|
2
|
+
from typing import Optional, Union
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
5
|
|
|
@@ -17,19 +17,17 @@ class SimpleAttribution(MapLayer):
|
|
|
17
17
|
text: Union[str, ft.Text]
|
|
18
18
|
"""
|
|
19
19
|
The attribution message to be displayed.
|
|
20
|
-
|
|
21
|
-
Value is of type `str` and `ft.Text`.
|
|
22
20
|
"""
|
|
23
21
|
|
|
24
|
-
alignment: ft.Alignment = field(default_factory=lambda: ft.Alignment.
|
|
22
|
+
alignment: ft.Alignment = field(default_factory=lambda: ft.Alignment.BOTTOM_RIGHT)
|
|
25
23
|
"""
|
|
26
24
|
The alignment of this attribution on the map.
|
|
27
25
|
"""
|
|
28
26
|
|
|
29
27
|
bgcolor: ft.ColorValue = ft.Colors.SURFACE
|
|
30
28
|
"""
|
|
31
|
-
The color of the box containing the `text
|
|
29
|
+
The color of the box containing the [`text`][..].
|
|
32
30
|
"""
|
|
33
31
|
|
|
34
|
-
on_click: ft.
|
|
32
|
+
on_click: Optional[ft.ControlEventHandler["SimpleAttribution"]] = None
|
|
35
33
|
"""Fired when this attribution is clicked/pressed."""
|
flet_map/source_attribution.py
CHANGED
|
@@ -6,7 +6,7 @@ import flet as ft
|
|
|
6
6
|
__all__ = ["ImageSourceAttribution", "SourceAttribution", "TextSourceAttribution"]
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
@dataclass
|
|
9
|
+
@dataclass
|
|
10
10
|
class SourceAttribution(ft.BaseControl):
|
|
11
11
|
"""
|
|
12
12
|
Abstract class for source attribution controls:
|
|
@@ -19,8 +19,10 @@ class SourceAttribution(ft.BaseControl):
|
|
|
19
19
|
@ft.control("ImageSourceAttribution")
|
|
20
20
|
class ImageSourceAttribution(SourceAttribution):
|
|
21
21
|
"""
|
|
22
|
-
An image attribution permanently displayed adjacent to the
|
|
23
|
-
|
|
22
|
+
An image attribution permanently displayed adjacent to the
|
|
23
|
+
open/close icon of a [`RichAttribution`][(p).] control.
|
|
24
|
+
For it to be displayed, it should be part of a
|
|
25
|
+
[`RichAttribution.attributions`][(p).] list.
|
|
24
26
|
|
|
25
27
|
Raises:
|
|
26
28
|
AssertionError: If the [`image`][(c).] is not visible.
|
|
@@ -29,7 +31,7 @@ class ImageSourceAttribution(SourceAttribution):
|
|
|
29
31
|
image: ft.Image
|
|
30
32
|
"""
|
|
31
33
|
The `Image` to be displayed.
|
|
32
|
-
|
|
34
|
+
|
|
33
35
|
Note:
|
|
34
36
|
Must be provided and visible.
|
|
35
37
|
"""
|
|
@@ -37,13 +39,14 @@ class ImageSourceAttribution(SourceAttribution):
|
|
|
37
39
|
height: ft.Number = 24.0
|
|
38
40
|
"""
|
|
39
41
|
The height of the image.
|
|
40
|
-
Should be the same as [`RichAttribution.permanent_height`][(p).],
|
|
42
|
+
Should be the same as [`RichAttribution.permanent_height`][(p).],
|
|
43
|
+
otherwise layout issues may occur.
|
|
41
44
|
"""
|
|
42
45
|
|
|
43
46
|
tooltip: Optional[str] = None
|
|
44
47
|
"""Tooltip text to be displayed when the image is hovered over."""
|
|
45
48
|
|
|
46
|
-
on_click: ft.
|
|
49
|
+
on_click: Optional[ft.ControlEventHandler["ImageSourceAttribution"]] = None
|
|
47
50
|
"""Fired when this attribution is clicked/pressed."""
|
|
48
51
|
|
|
49
52
|
def before_update(self):
|
|
@@ -55,7 +58,8 @@ class ImageSourceAttribution(SourceAttribution):
|
|
|
55
58
|
class TextSourceAttribution(SourceAttribution):
|
|
56
59
|
"""
|
|
57
60
|
A text source attribution displayed on the Map.
|
|
58
|
-
For it to be displayed, it should be part of a
|
|
61
|
+
For it to be displayed, it should be part of a
|
|
62
|
+
[`RichAttribution.attributions`][(p).] list.
|
|
59
63
|
"""
|
|
60
64
|
|
|
61
65
|
text: str
|
|
@@ -69,5 +73,5 @@ class TextSourceAttribution(SourceAttribution):
|
|
|
69
73
|
Whether to add the '©' character to the start of [`text`][..] automatically.
|
|
70
74
|
"""
|
|
71
75
|
|
|
72
|
-
on_click: ft.
|
|
76
|
+
on_click: Optional[ft.ControlEventHandler["TextSourceAttribution"]] = None
|
|
73
77
|
"""Fired when this attribution is clicked/pressed."""
|
flet_map/tile_layer.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from dataclasses import field
|
|
2
|
-
from typing import
|
|
2
|
+
from typing import Optional
|
|
3
3
|
|
|
4
4
|
import flet as ft
|
|
5
5
|
|
|
@@ -20,17 +20,20 @@ class TileLayer(MapLayer):
|
|
|
20
20
|
Displays square raster images in a continuous grid,
|
|
21
21
|
sourced from the provided [`url_template`][(c).] and [`fallback_url`][(c).].
|
|
22
22
|
|
|
23
|
-
Typically the first layer to be added to a [`Map`][(p).],
|
|
23
|
+
Typically the first layer to be added to a [`Map`][(p).],
|
|
24
|
+
as it provides the tiles on which
|
|
24
25
|
other layers are displayed.
|
|
25
26
|
|
|
26
27
|
Raises:
|
|
27
28
|
AssertionError: If one or more of the following is negative:
|
|
28
|
-
[`tile_size`][(c).], [`min_native_zoom`][(c).],
|
|
29
|
+
[`tile_size`][(c).], [`min_native_zoom`][(c).],
|
|
30
|
+
[`max_native_zoom`][(c).], [`zoom_offset`][(c).],
|
|
31
|
+
[`max_zoom`][(c).], [`min_zoom`][(c).]
|
|
29
32
|
"""
|
|
30
33
|
|
|
31
34
|
url_template: str
|
|
32
35
|
"""
|
|
33
|
-
The URL template is a string that contains placeholders,
|
|
36
|
+
The URL template is a string that contains placeholders,
|
|
34
37
|
which, when filled in, create a URL/URI to a specific tile.
|
|
35
38
|
"""
|
|
36
39
|
|
|
@@ -38,20 +41,21 @@ class TileLayer(MapLayer):
|
|
|
38
41
|
"""
|
|
39
42
|
Fallback URL template, used if an error occurs when fetching tiles from
|
|
40
43
|
the [`url_template`][..].
|
|
41
|
-
|
|
44
|
+
|
|
42
45
|
Note that specifying this (non-none) will result in tiles not being cached
|
|
43
46
|
in memory. This is to avoid issues where the [`url_template`][..] is flaky, to
|
|
44
47
|
prevent different tilesets being displayed at the same time.
|
|
45
|
-
|
|
46
|
-
It is expected that this follows the same retina support behaviour
|
|
48
|
+
|
|
49
|
+
It is expected that this follows the same retina support behaviour
|
|
50
|
+
as [`url_template`][..].
|
|
47
51
|
"""
|
|
48
52
|
|
|
49
|
-
subdomains:
|
|
53
|
+
subdomains: list[str] = field(default_factory=lambda: ["a", "b", "c"])
|
|
50
54
|
"""
|
|
51
55
|
List of subdomains used in the URL template.
|
|
52
56
|
|
|
53
|
-
For example, if [`subdomains`][..] is set to `["a", "b", "c"]` and the
|
|
54
|
-
`url_template` is `"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"`,
|
|
57
|
+
For example, if [`subdomains`][..] is set to `["a", "b", "c"]` and the
|
|
58
|
+
`url_template` is `"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"`,
|
|
55
59
|
the resulting tile URLs will be:
|
|
56
60
|
|
|
57
61
|
- `"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png"`
|
|
@@ -61,7 +65,7 @@ class TileLayer(MapLayer):
|
|
|
61
65
|
|
|
62
66
|
tile_bounds: Optional[MapLatitudeLongitudeBounds] = None
|
|
63
67
|
"""
|
|
64
|
-
Defines the bounds of the map.
|
|
68
|
+
Defines the bounds of the map.
|
|
65
69
|
Only tiles that fall within these bounds will be loaded.
|
|
66
70
|
"""
|
|
67
71
|
|
|
@@ -69,7 +73,7 @@ class TileLayer(MapLayer):
|
|
|
69
73
|
"""
|
|
70
74
|
The size in pixels of each tile image.
|
|
71
75
|
Should be a positive power of 2.
|
|
72
|
-
|
|
76
|
+
|
|
73
77
|
Note:
|
|
74
78
|
Must be greater than or equal to `0.0`.
|
|
75
79
|
"""
|
|
@@ -80,10 +84,10 @@ class TileLayer(MapLayer):
|
|
|
80
84
|
|
|
81
85
|
Tiles from below this zoom level will not be displayed, instead tiles at
|
|
82
86
|
this zoom level will be displayed and scaled.
|
|
83
|
-
|
|
87
|
+
|
|
84
88
|
This should usually be 0 (as default), as most tile sources will support
|
|
85
89
|
zoom levels onwards from this.
|
|
86
|
-
|
|
90
|
+
|
|
87
91
|
Note:
|
|
88
92
|
Must be greater than or equal to `0.0`.
|
|
89
93
|
"""
|
|
@@ -94,23 +98,24 @@ class TileLayer(MapLayer):
|
|
|
94
98
|
|
|
95
99
|
Tiles from above this zoom level will not be displayed, instead tiles at
|
|
96
100
|
this zoom level will be displayed and scaled.
|
|
97
|
-
|
|
101
|
+
|
|
98
102
|
Most tile servers support up to zoom level `19`, which is the default.
|
|
99
103
|
Otherwise, this should be specified.
|
|
100
|
-
|
|
104
|
+
|
|
101
105
|
Note:
|
|
102
106
|
Must be greater than or equal to `0.0`.
|
|
103
107
|
"""
|
|
104
108
|
|
|
105
109
|
zoom_reverse: bool = False
|
|
106
110
|
"""
|
|
107
|
-
Whether the zoom number used in tile URLs will be reversed
|
|
111
|
+
Whether the zoom number used in tile URLs will be reversed
|
|
112
|
+
(`max_zoom - zoom` instead of `zoom`).
|
|
108
113
|
"""
|
|
109
114
|
|
|
110
115
|
zoom_offset: ft.Number = 0.0
|
|
111
116
|
"""
|
|
112
117
|
The zoom number used in tile URLs will be offset with this value.
|
|
113
|
-
|
|
118
|
+
|
|
114
119
|
Note:
|
|
115
120
|
Must be greater than or equal to `0.0`.
|
|
116
121
|
"""
|
|
@@ -137,14 +142,15 @@ class TileLayer(MapLayer):
|
|
|
137
142
|
enable_retina_mode: bool = False
|
|
138
143
|
"""
|
|
139
144
|
Whether to enable retina mode.
|
|
140
|
-
Retina mode improves the resolution of map tiles, particularly on
|
|
145
|
+
Retina mode improves the resolution of map tiles, particularly on
|
|
146
|
+
high density displays.
|
|
141
147
|
"""
|
|
142
148
|
|
|
143
|
-
additional_options:
|
|
149
|
+
additional_options: dict[str, str] = field(default_factory=dict)
|
|
144
150
|
"""
|
|
145
151
|
Static information that should replace placeholders in the [`url_template`][..].
|
|
146
152
|
Applying API keys, for example, is a good usecase of this parameter.
|
|
147
|
-
|
|
153
|
+
|
|
148
154
|
Example:
|
|
149
155
|
```python
|
|
150
156
|
TileLayer(
|
|
@@ -162,12 +168,12 @@ class TileLayer(MapLayer):
|
|
|
162
168
|
The maximum zoom level up to which this layer will be displayed (inclusive).
|
|
163
169
|
The main usage for this property is to display a different `TileLayer`
|
|
164
170
|
when zoomed far in.
|
|
165
|
-
|
|
171
|
+
|
|
166
172
|
Prefer [`max_native_zoom`][..] for setting the maximum zoom level supported by the
|
|
167
|
-
tile source.
|
|
168
|
-
|
|
173
|
+
tile source.
|
|
174
|
+
|
|
169
175
|
Typically set to infinity so that there are tiles always displayed.
|
|
170
|
-
|
|
176
|
+
|
|
171
177
|
Note:
|
|
172
178
|
Must be greater than or equal to `0.0`.
|
|
173
179
|
"""
|
|
@@ -176,7 +182,7 @@ class TileLayer(MapLayer):
|
|
|
176
182
|
"""
|
|
177
183
|
The minimum zoom level at which this layer is displayed (inclusive).
|
|
178
184
|
Typically `0.0`.
|
|
179
|
-
|
|
185
|
+
|
|
180
186
|
Note:
|
|
181
187
|
Must be greater than or equal to `0.0`.
|
|
182
188
|
"""
|
|
@@ -184,21 +190,21 @@ class TileLayer(MapLayer):
|
|
|
184
190
|
error_image_src: Optional[str] = None
|
|
185
191
|
"""
|
|
186
192
|
The source of the tile image to show in place of the tile that failed to load.
|
|
187
|
-
|
|
193
|
+
|
|
188
194
|
See [`on_image_error`][..] property for details on the error.
|
|
189
195
|
"""
|
|
190
196
|
|
|
191
|
-
evict_error_tile_strategy: Optional[
|
|
192
|
-
TileLayerEvictErrorTileStrategy
|
|
193
|
-
|
|
197
|
+
evict_error_tile_strategy: Optional[TileLayerEvictErrorTileStrategy] = (
|
|
198
|
+
TileLayerEvictErrorTileStrategy.NONE
|
|
199
|
+
)
|
|
194
200
|
"""
|
|
195
|
-
If a tile was loaded with error,
|
|
201
|
+
If a tile was loaded with error,
|
|
196
202
|
the tile provider will be asked to evict the image based on this strategy.
|
|
197
203
|
"""
|
|
198
204
|
|
|
199
205
|
display_mode: TileDisplay = field(default_factory=lambda: FadeInTileDisplay())
|
|
200
206
|
"""
|
|
201
|
-
|
|
207
|
+
|
|
202
208
|
Defines how tiles are displayed on the map.
|
|
203
209
|
"""
|
|
204
210
|
|
|
@@ -207,11 +213,12 @@ class TileLayer(MapLayer):
|
|
|
207
213
|
The package name of the user agent.
|
|
208
214
|
"""
|
|
209
215
|
|
|
210
|
-
on_image_error: ft.
|
|
216
|
+
on_image_error: Optional[ft.ControlEventHandler["TileLayer"]] = None
|
|
211
217
|
"""
|
|
212
218
|
Fires if an error occurs when fetching the tiles.
|
|
213
|
-
|
|
214
|
-
Event handler argument `data` property contains
|
|
219
|
+
|
|
220
|
+
Event handler argument [`data`][flet.Event.data] property contains
|
|
221
|
+
information about the error.
|
|
215
222
|
"""
|
|
216
223
|
|
|
217
224
|
def before_update(self):
|
|
@@ -220,10 +227,12 @@ class TileLayer(MapLayer):
|
|
|
220
227
|
f"tile_size must be greater than or equal to 0, got {self.tile_size}"
|
|
221
228
|
)
|
|
222
229
|
assert self.min_native_zoom >= 0, (
|
|
223
|
-
f"min_native_zoom must be greater than or equal to 0,
|
|
230
|
+
f"min_native_zoom must be greater than or equal to 0, "
|
|
231
|
+
f"got {self.min_native_zoom}"
|
|
224
232
|
)
|
|
225
233
|
assert self.max_native_zoom >= 0, (
|
|
226
|
-
f"max_native_zoom must be greater than or equal to 0,
|
|
234
|
+
f"max_native_zoom must be greater than or equal to 0, "
|
|
235
|
+
f"got {self.max_native_zoom}"
|
|
227
236
|
)
|
|
228
237
|
assert self.zoom_offset >= 0, (
|
|
229
238
|
f"zoom_offset must be greater than or equal to 0, got {self.zoom_offset}"
|