flet-map 0.1.0.dev2__py3-none-any.whl → 0.2.0.dev45__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.

Files changed (37) hide show
  1. flet_map/__init__.py +30 -19
  2. flet_map/circle_layer.py +46 -139
  3. flet_map/map.py +462 -604
  4. flet_map/map_layer.py +14 -20
  5. flet_map/marker_layer.py +83 -169
  6. flet_map/polygon_layer.py +95 -232
  7. flet_map/polyline_layer.py +85 -262
  8. flet_map/rich_attribution.py +48 -126
  9. flet_map/simple_attribution.py +24 -75
  10. flet_map/source_attribution.py +73 -0
  11. flet_map/tile_layer.py +224 -266
  12. flet_map/types.py +953 -0
  13. flet_map-0.2.0.dev45.dist-info/METADATA +66 -0
  14. flet_map-0.2.0.dev45.dist-info/RECORD +35 -0
  15. {flet_map-0.1.0.dev2.dist-info → flet_map-0.2.0.dev45.dist-info}/WHEEL +1 -1
  16. flet_map-0.2.0.dev45.dist-info/licenses/LICENSE +201 -0
  17. flutter/flet_map/CHANGELOG.md +4 -0
  18. flutter/flet_map/lib/flet_map.dart +1 -1
  19. flutter/flet_map/lib/src/circle_layer.dart +15 -25
  20. flutter/flet_map/lib/src/extension.dart +37 -0
  21. flutter/flet_map/lib/src/map.dart +93 -105
  22. flutter/flet_map/lib/src/marker_layer.dart +21 -33
  23. flutter/flet_map/lib/src/polygon_layer.dart +32 -52
  24. flutter/flet_map/lib/src/polyline_layer.dart +41 -64
  25. flutter/flet_map/lib/src/rich_attribution.dart +34 -34
  26. flutter/flet_map/lib/src/simple_attribution.dart +9 -23
  27. flutter/flet_map/lib/src/tile_layer.dart +47 -60
  28. flutter/flet_map/lib/src/utils/attribution_alignment.dart +1 -3
  29. flutter/flet_map/lib/src/utils/map.dart +257 -203
  30. flutter/flet_map/pubspec.lock +179 -130
  31. flutter/flet_map/pubspec.yaml +10 -5
  32. flet_map/text_source_attribution.py +0 -87
  33. flet_map-0.1.0.dev2.dist-info/METADATA +0 -168
  34. flet_map-0.1.0.dev2.dist-info/RECORD +0 -34
  35. flutter/flet_map/lib/src/create_control.dart +0 -70
  36. flutter/flet_map/lib/src/text_source_attribution.dart +0 -29
  37. {flet_map-0.1.0.dev2.dist-info → flet_map-0.2.0.dev45.dist-info}/top_level.txt +0 -0
@@ -6,45 +6,33 @@ import 'package:flutter_map_animations/flutter_map_animations.dart';
6
6
  import 'utils/map.dart';
7
7
 
8
8
  class MarkerLayerControl extends StatelessWidget with FletStoreMixin {
9
- final Control? parent;
10
9
  final Control control;
11
- final List<Control> children;
12
- final bool parentDisabled;
13
10
 
14
- const MarkerLayerControl(
15
- {super.key,
16
- required this.parent,
17
- required this.control,
18
- required this.children,
19
- required this.parentDisabled});
11
+ const MarkerLayerControl({super.key, required this.control});
20
12
 
21
13
  @override
22
14
  Widget build(BuildContext context) {
23
15
  debugPrint("MarkerLayerControl build: ${control.id}");
16
+ var markers = control
17
+ .children("markers")
18
+ .where((c) => c.type == "Marker")
19
+ .map((marker) {
20
+ return AnimatedMarker(
21
+ point: parseLatLng(marker.get("coordinates"))!,
22
+ rotate: marker.getBool("rotate"),
23
+ height: marker.getDouble("height", 30.0)!,
24
+ width: marker.getDouble("width", 30.0)!,
25
+ alignment: marker.getAlignment("alignment"),
26
+ builder: (BuildContext context, Animation<double> animation) {
27
+ return marker.buildWidget("content") ??
28
+ const ErrorControl("content must be provided and visible");
29
+ });
30
+ }).toList();
24
31
 
25
- return withControls(control.childIds, (context, markersView) {
26
- debugPrint("MarkerLayerControlState build: ${control.id}");
27
-
28
- var markers = markersView.controlViews
29
- .where((c) => c.control.type == "map_marker" && c.control.isVisible)
30
- .map((marker) {
31
- return AnimatedMarker(
32
- point: parseLatLng(marker.control, "coordinates")!,
33
- rotate: marker.control.attrBool("rotate"),
34
- height: marker.control.attrDouble("height", 30)!,
35
- width: marker.control.attrDouble("width", 30)!,
36
- alignment: parseAlignment(marker.control, "alignment"),
37
- builder: (BuildContext context, Animation<double> animation) {
38
- return createControl(
39
- control, marker.control.childIds.first, parentDisabled);
40
- });
41
- }).toList();
42
-
43
- return AnimatedMarkerLayer(
44
- markers: markers,
45
- rotate: control.attrBool("rotate", false)!,
46
- alignment: parseAlignment(control, "alignment", Alignment.center)!,
47
- );
48
- });
32
+ return AnimatedMarkerLayer(
33
+ markers: markers,
34
+ rotate: control.getBool("rotate", false)!,
35
+ alignment: control.getAlignment("alignment", Alignment.center)!,
36
+ );
49
37
  }
50
38
  }
@@ -1,6 +1,3 @@
1
- import 'dart:convert';
2
-
3
- import 'package:collection/collection.dart';
4
1
  import 'package:flet/flet.dart';
5
2
  import 'package:flutter/material.dart';
6
3
  import 'package:flutter_map/flutter_map.dart';
@@ -8,61 +5,44 @@ import 'package:flutter_map/flutter_map.dart';
8
5
  import 'utils/map.dart';
9
6
 
10
7
  class PolygonLayerControl extends StatelessWidget with FletStoreMixin {
11
- final Control? parent;
12
8
  final Control control;
13
9
 
14
- const PolygonLayerControl(
15
- {super.key, required this.parent, required this.control});
10
+ const PolygonLayerControl({super.key, required this.control});
16
11
 
17
12
  @override
18
13
  Widget build(BuildContext context) {
19
14
  debugPrint("PolygonLayerControl build: ${control.id}");
20
15
 
21
- return withControls(control.childIds, (context, polygonsView) {
22
- debugPrint("PolygonLayerControlState build: ${control.id}");
23
-
24
- var polygons = polygonsView.controlViews
25
- .where((c) =>
26
- c.control.type == "map_polygon_marker" && c.control.isVisible)
27
- .map((polygon) {
28
- var strokeCap = parseStrokeCap(
29
- polygon.control.attrString("strokeCap"), StrokeCap.round)!;
30
- var strokeJoin = parseStrokeJoin(
31
- polygon.control.attrString("strokeJoin"), StrokeJoin.round)!;
32
- var coordinates = polygon.control.attrString("coordinates");
33
- return Polygon(
34
- borderStrokeWidth:
35
- polygon.control.attrDouble("borderStrokeWidth", 0)!,
36
- borderColor: polygon.control.attrColor("borderColor", context) ??
37
- const Color(0xFFFFFF00),
38
- color: polygon.control.attrColor("color", context) ??
39
- const Color(0xFF00FF00),
40
- disableHolesBorder:
41
- polygon.control.attrBool("disableHolesBorder", false)!,
42
- rotateLabel: polygon.control.attrBool("rotateLabel", false)!,
43
- label: polygon.control.attrString("label"),
44
- labelStyle: parseTextStyle(
45
- Theme.of(context), polygon.control, "labelTextStyle") ??
46
- const TextStyle(),
47
- strokeCap: strokeCap,
48
- strokeJoin: strokeJoin,
49
- points: coordinates != null
50
- ? (jsonDecode(coordinates) as List)
51
- .map((e) => latLngFromJson(e))
52
- .whereNotNull()
53
- .toList()
54
- : []);
55
- }).toList();
56
-
57
- return PolygonLayer(
58
- polygons: polygons,
59
- polygonCulling: control.attrBool("polygonCulling", false)!,
60
- polygonLabels: control.attrBool("polygonLabels", true)!,
61
- drawLabelsLast: control.attrBool("drawLabelsLast", false)!,
62
- simplificationTolerance:
63
- control.attrDouble("simplificationTolerance", 0.5)!,
64
- useAltRendering: control.attrBool("useAlternativeRendering", false)!,
65
- );
66
- });
16
+ var polygons = control
17
+ .children("polygons")
18
+ .where((c) => c.type == "PolygonMarker")
19
+ .map((polygon) {
20
+ return Polygon(
21
+ borderStrokeWidth: polygon.getDouble("border_stroke_width", 0)!,
22
+ borderColor: polygon.getColor("border_color", context, Colors.green)!,
23
+ color: polygon.getColor("color", context, Colors.green)!,
24
+ disableHolesBorder: polygon.getBool("disable_holes_border", false)!,
25
+ rotateLabel: polygon.getBool("rotate_label", false)!,
26
+ label: polygon.getString("label"),
27
+ labelStyle: polygon.getTextStyle(
28
+ "label_text_style", Theme.of(context), const TextStyle())!,
29
+ strokeCap: polygon.getStrokeCap("stroke_cap", StrokeCap.round)!,
30
+ strokeJoin: polygon.getStrokeJoin("stroke_join", StrokeJoin.round)!,
31
+ points: polygon
32
+ .get("coordinates", [])!
33
+ .map((c) => parseLatLng(c))
34
+ .nonNulls
35
+ .toList());
36
+ }).toList();
37
+
38
+ return PolygonLayer(
39
+ polygons: polygons,
40
+ polygonCulling: control.getBool("polygon_culling", true)!,
41
+ polygonLabels: control.getBool("polygon_labels", true)!,
42
+ drawLabelsLast: control.getBool("draw_labels_last", false)!,
43
+ simplificationTolerance:
44
+ control.getDouble("simplification_tolerance", 0.3)!,
45
+ useAltRendering: control.getBool("use_alternative_rendering", false)!,
46
+ );
67
47
  }
68
48
  }
@@ -1,6 +1,3 @@
1
- import 'dart:convert';
2
-
3
- import 'package:collection/collection.dart';
4
1
  import 'package:flet/flet.dart';
5
2
  import 'package:flutter/material.dart';
6
3
  import 'package:flutter_map/flutter_map.dart';
@@ -8,73 +5,53 @@ import 'package:flutter_map/flutter_map.dart';
8
5
  import 'utils/map.dart';
9
6
 
10
7
  class PolylineLayerControl extends StatelessWidget with FletStoreMixin {
11
- final Control? parent;
12
8
  final Control control;
13
- final List<Control> children;
14
9
 
15
- const PolylineLayerControl(
16
- {super.key,
17
- required this.parent,
18
- required this.control,
19
- required this.children});
10
+ const PolylineLayerControl({super.key, required this.control});
20
11
 
21
12
  @override
22
13
  Widget build(BuildContext context) {
23
14
  debugPrint("PolylineLayerControl build: ${control.id}");
24
15
 
25
- return withControls(control.childIds, (context, polylinesView) {
26
- debugPrint("PolylineLayerControlState build: ${control.id}");
27
-
28
- var polylines = polylinesView.controlViews
29
- .where((c) =>
30
- c.control.type == "map_polyline_marker" && c.control.isVisible)
31
- .map<Polyline>((polyline) {
32
- var coordinates = polyline.control.attrString("coordinates");
33
- var colorsStop = polyline.control.attrString("colorsStop");
34
- var gradientColors = polyline.control.attrString("gradientColors");
35
- return Polyline(
36
- borderStrokeWidth:
37
- polyline.control.attrDouble("borderStrokeWidth", 0)!,
38
- borderColor: polyline.control
39
- .attrColor("borderColor", context, const Color(0xFFFFFF00))!,
40
- color: polyline.control
41
- .attrColor("color", context, const Color(0xFF00FF00))!,
42
- pattern: parseStrokePattern(polyline.control, "strokePattern") ??
43
- const StrokePattern.solid(),
44
- strokeCap: parseStrokeCap(
45
- polyline.control.attrString("strokeCap"), StrokeCap.round)!,
46
- strokeJoin: parseStrokeJoin(
47
- polyline.control.attrString("strokeJoin"), StrokeJoin.round)!,
48
- strokeWidth: polyline.control.attrDouble("strokeWidth", 1.0)!,
49
- useStrokeWidthInMeter:
50
- polyline.control.attrBool("useStrokeWidthInMeter", false)!,
51
- colorsStop: colorsStop != null
52
- ? (jsonDecode(colorsStop) as List)
53
- .map((e) => parseDouble(e))
54
- .whereNotNull()
55
- .toList()
56
- : null,
57
- gradientColors: gradientColors != null
58
- ? (jsonDecode(gradientColors) as List)
59
- .map((e) => parseColor(Theme.of(context), e))
60
- .whereNotNull()
61
- .toList()
62
- : null,
63
- points: coordinates != null
64
- ? (jsonDecode(coordinates) as List)
65
- .map((e) => latLngFromJson(e))
66
- .whereNotNull()
67
- .toList()
68
- : []);
69
- }).toList();
70
-
71
- return PolylineLayer(
72
- polylines: polylines,
73
- cullingMargin: control.attrDouble("cullingMargin", 10)!,
74
- minimumHitbox: control.attrDouble("minHittableRadius", 10)!,
75
- simplificationTolerance:
76
- control.attrDouble("simplificationTolerance", 0.4)!,
77
- );
78
- });
16
+ var polylines = control
17
+ .children("polygons")
18
+ .where((c) => c.type == "PolygonMarker")
19
+ .map((polyline) {
20
+ return Polyline(
21
+ borderStrokeWidth: polyline.getDouble("border_stroke_width", 0)!,
22
+ borderColor:
23
+ polyline.getColor("border_color", context, Colors.yellow)!,
24
+ color: polyline.getColor("color", context, Colors.yellow)!,
25
+ pattern: parseStrokePattern(
26
+ polyline.get("stroke_pattern"), const StrokePattern.solid())!,
27
+ strokeCap: polyline.getStrokeCap("stroke_cap", StrokeCap.round)!,
28
+ strokeJoin: polyline.getStrokeJoin("stroke_join", StrokeJoin.round)!,
29
+ strokeWidth: polyline.getDouble("stroke_width", 1.0)!,
30
+ useStrokeWidthInMeter:
31
+ polyline.getBool("use_stroke_width_in_meter", false)!,
32
+ colorsStop: polyline
33
+ .get("colors_stop", [])!
34
+ .map((e) => parseDouble(e))
35
+ .nonNulls
36
+ .toList(),
37
+ gradientColors: polyline
38
+ .get("gradient_colors", [])!
39
+ .map((e) => parseColor(e, Theme.of(context)))
40
+ .nonNulls
41
+ .toList(),
42
+ points: polyline
43
+ .get("coordinates", [])!
44
+ .map((c) => parseLatLng(c))
45
+ .nonNulls
46
+ .toList());
47
+ }).toList();
48
+
49
+ return PolylineLayer(
50
+ polylines: polylines,
51
+ cullingMargin: control.getDouble("culling_margin", 10.0)!,
52
+ minimumHitbox: control.getDouble("min_hittable_radius", 10.0)!,
53
+ simplificationTolerance:
54
+ control.getDouble("simplification_tolerance", 0.3)!,
55
+ );
79
56
  }
80
57
  }
@@ -5,15 +5,9 @@ import 'package:flutter_map/flutter_map.dart';
5
5
  import 'utils/attribution_alignment.dart';
6
6
 
7
7
  class RichAttributionControl extends StatefulWidget {
8
- final Control? parent;
9
8
  final Control control;
10
- final FletControlBackend backend;
11
9
 
12
- const RichAttributionControl(
13
- {super.key,
14
- this.parent,
15
- required this.control,
16
- required this.backend});
10
+ const RichAttributionControl({super.key, required this.control});
17
11
 
18
12
  @override
19
13
  State<RichAttributionControl> createState() => _RichAttributionControlState();
@@ -25,37 +19,43 @@ class _RichAttributionControlState extends State<RichAttributionControl>
25
19
  Widget build(BuildContext context) {
26
20
  debugPrint("RichAttributionControl build: ${widget.control.id}");
27
21
 
28
- return withControls(widget.control.childIds, (context, attributionsView) {
29
- debugPrint("RichAttributionControlState build: ${widget.control.id}");
30
-
31
- var attributions = attributionsView.controlViews
32
- .map((v) => v.control)
33
- .where((c) => c.type == "map_text_source_attribution" && c.isVisible)
34
- .map((Control itemCtrl) {
35
- return TextSourceAttribution(
36
- itemCtrl.attrs["text"] ?? "Placeholder Text",
37
- textStyle: parseTextStyle(Theme.of(context), itemCtrl, "textStyle"),
38
- onTap: () {
39
- widget.backend.triggerControlEvent(itemCtrl.id, "click");
40
- },
41
- prependCopyright: itemCtrl.attrBool("prependCopyright", true)!,
42
- );
43
- }).toList();
44
-
45
- return RichAttributionWidget(
22
+ var attributions = widget.control
23
+ .children("attributions")
24
+ .map((Control c) {
25
+ if (c.type == "TextSourceAttribution") {
26
+ return TextSourceAttribution(
27
+ c.getString("text", "Placeholder Text")!,
28
+ textStyle: c.getTextStyle("text_style", Theme.of(context)),
29
+ onTap: () => c.triggerEvent("click"),
30
+ prependCopyright: c.getBool("prepend_copyright", true)!,
31
+ );
32
+ } else if (c.type == "ImageSourceAttribution") {
33
+ var image = c.buildWidget("image");
34
+ if (image == null) return null;
35
+ return LogoSourceAttribution(
36
+ image,
37
+ height: c.getDouble("height", 24.0)!,
38
+ tooltip: c.getString("tooltip"),
39
+ onTap: () => c.triggerEvent("click"),
40
+ );
41
+ }
42
+ })
43
+ .nonNulls
44
+ .toList();
45
+
46
+ return RichAttributionWidget(
46
47
  attributions: attributions,
47
- permanentHeight: widget.control.attrDouble("permanentHeight", 24)!,
48
- popupBackgroundColor: widget.control.attrColor("popupBgColor", context),
48
+ permanentHeight: widget.control.getDouble("permanent_height", 24.0)!,
49
+ popupBackgroundColor: widget.control.getColor(
50
+ "popup_bgcolor", context, Theme.of(context).colorScheme.surface),
49
51
  showFlutterMapAttribution:
50
- widget.control.attrBool("showFlutterMapAttribution", true)!,
52
+ widget.control.getBool("show_flutter_map_attribution", true)!,
51
53
  alignment: parseAttributionAlignment(
52
- widget.control.attrString("alignment"),
54
+ widget.control.getString("alignment"),
53
55
  AttributionAlignment.bottomRight)!,
54
56
  popupBorderRadius:
55
- parseBorderRadius(widget.control, "popupBorderRadius"),
56
- popupInitialDisplayDuration: Duration(
57
- seconds: widget.control.attrInt("popupInitialDisplayDuration", 0)!),
58
- );
59
- });
57
+ widget.control.getBorderRadius("popup_border_radius"),
58
+ popupInitialDisplayDuration: widget.control
59
+ .getDuration("popup_initial_display_duration", Duration.zero)!);
60
60
  }
61
61
  }
@@ -1,37 +1,23 @@
1
1
  import 'package:flet/flet.dart';
2
2
  import 'package:flutter/material.dart';
3
- import 'package:flutter/widgets.dart';
4
3
  import 'package:flutter_map/flutter_map.dart';
5
4
 
6
- class SimpleAttributionControl extends StatefulWidget {
7
- final Control? parent;
5
+ class SimpleAttributionControl extends StatelessWidget {
8
6
  final Control control;
9
- final FletControlBackend backend;
10
7
 
11
- const SimpleAttributionControl(
12
- {super.key,
13
- this.parent,
14
- required this.control,
15
- required this.backend});
8
+ const SimpleAttributionControl({super.key, required this.control});
16
9
 
17
- @override
18
- State<SimpleAttributionControl> createState() =>
19
- _SimpleAttributionControlState();
20
- }
21
-
22
- class _SimpleAttributionControlState extends State<SimpleAttributionControl> {
23
10
  @override
24
11
  Widget build(BuildContext context) {
25
- debugPrint("SimpleAttributionControl build: ${widget.control.id}");
12
+ debugPrint("SimpleAttributionControl build: ${control.id}");
13
+ var text = control.buildTextOrWidget("text");
26
14
 
27
15
  return SimpleAttributionWidget(
28
- source: Text(widget.control.attrString("text", "Placeholder Text")!),
29
- onTap: () {
30
- widget.backend.triggerControlEvent(widget.control.id, "click");
31
- },
32
- backgroundColor: widget.control.attrColor("backgroundColor", context),
33
- alignment:
34
- parseAlignment(widget.control, "alignment", Alignment.bottomRight)!,
16
+ source: text is Text ? text : const Text("Placeholder Text"),
17
+ onTap: () => control.triggerEvent("click"),
18
+ backgroundColor: control.getColor(
19
+ "bgcolor", context, Theme.of(context).colorScheme.surface)!,
20
+ alignment: control.getAlignment("alignment", Alignment.bottomRight)!,
35
21
  );
36
22
  }
37
23
  }
@@ -1,5 +1,3 @@
1
- import 'dart:convert';
2
-
3
1
  import 'package:flet/flet.dart';
4
2
  import 'package:flutter/material.dart';
5
3
  import 'package:flutter/widgets.dart';
@@ -8,73 +6,62 @@ import 'package:flutter_map_cancellable_tile_provider/flutter_map_cancellable_ti
8
6
 
9
7
  import './utils/map.dart';
10
8
 
11
- class TileLayerControl extends StatelessWidget with FletStoreMixin {
12
- final Control? parent;
9
+ class TileLayerControl extends StatelessWidget {
13
10
  final Control control;
14
- final FletControlBackend backend;
15
11
 
16
- const TileLayerControl(
17
- {super.key,
18
- required this.parent,
19
- required this.control,
20
- required this.backend});
12
+ const TileLayerControl({super.key, required this.control});
21
13
 
22
14
  @override
23
15
  Widget build(BuildContext context) {
24
16
  debugPrint("TileLayerControl build: ${control.id}");
25
17
 
26
- return withPageArgs((context, pageArgs) {
27
- var errorImageSrc = control.attrString("errorImageSrc");
28
-
29
- ImageProvider<Object>? errorImage;
30
-
31
- if (errorImageSrc != null) {
32
- var assetSrc =
33
- getAssetSrc((errorImageSrc), pageArgs.pageUri!, pageArgs.assetsDir);
18
+ var errorImageSrc = control.getString("errorImageSrc");
19
+ ImageProvider<Object>? errorImage;
34
20
 
35
- if (assetSrc.isFile) {
36
- // from File
37
- errorImage = AssetImage(assetSrc.path);
38
- } else {
39
- // URL
40
- errorImage = NetworkImage(assetSrc.path);
41
- }
21
+ if (errorImageSrc != null) {
22
+ var assetSrc = control.backend.getAssetSource(errorImageSrc);
23
+ if (assetSrc.isFile) {
24
+ // from File
25
+ errorImage = AssetImage(assetSrc.path);
26
+ } else {
27
+ // URL
28
+ errorImage = NetworkImage(assetSrc.path);
42
29
  }
43
- var subdomains = control.attrString("subdomains");
44
- var additionalOptions = control.attrString("additionalOptions");
45
- Widget tile = TileLayer(
46
- urlTemplate: control.attrString("urlTemplate", "")!,
47
- fallbackUrl: control.attrString("fallbackUrl", "")!,
48
- subdomains: subdomains != null
49
- ? jsonDecode(subdomains).cast<String>()
50
- : ['a', 'b', 'c'],
51
- tileProvider: CancellableNetworkTileProvider(),
52
- tileDisplay: const TileDisplay.fadeIn(),
53
- tileSize: control.attrDouble("tileSize", 256)!,
54
- minNativeZoom: control.attrInt("minNativeZoom", 0)!,
55
- maxNativeZoom: control.attrInt("maxNativeZoom", 19)!,
56
- zoomReverse: control.attrBool("zoomReverse", false)!,
57
- zoomOffset: control.attrDouble("zoomOffset", 0)!,
58
- keepBuffer: control.attrInt("keepBuffer", 2)!,
59
- panBuffer: control.attrInt("panBuffer", 1)!,
60
- tms: control.attrBool("enableTms", false)!,
61
- tileBounds: parseLatLngBounds(control, "tileBounds"),
62
- retinaMode: control.attrBool("enableRetinaMode"),
63
- maxZoom: control.attrDouble("maxZoom", double.infinity)!,
64
- minZoom: control.attrDouble("minZoom", 0)!,
65
- evictErrorTileStrategy: parseEvictErrorTileStrategy(
66
- control.attrString("evictErrorTileStrategy"),
67
- EvictErrorTileStrategy.none)!,
68
- errorImage: errorImage,
69
- errorTileCallback: (TileImage t, Object o, StackTrace? s) {
70
- backend.triggerControlEvent(control.id, "imageError");
71
- },
72
- additionalOptions: additionalOptions != null
73
- ? (jsonDecode(additionalOptions) as Map)
74
- .map((k, v) => MapEntry(k.toString(), v.toString()))
75
- : const {});
30
+ }
31
+ Widget tileLayer = TileLayer(
32
+ urlTemplate: control.getString("url_template"),
33
+ fallbackUrl: control.getString("fallback_url"),
34
+ subdomains: control
35
+ .get<List>("subdomains")
36
+ ?.map((e) => e.toString())
37
+ .toList() ??
38
+ ['a', 'b', 'c'],
39
+ tileProvider: CancellableNetworkTileProvider(),
40
+ tileDisplay: parseTileDisplay(
41
+ control.get("display_mode"), const TileDisplay.fadeIn())!,
42
+ tileDimension: control.getInt("tile_size", 256)!,
43
+ userAgentPackageName:
44
+ control.getString("user_agent_package_name", 'unknown')!,
45
+ minNativeZoom: control.getInt("min_native_zoom", 0)!,
46
+ maxNativeZoom: control.getInt("max_native_zoom", 19)!,
47
+ zoomReverse: control.getBool("zoom_reverse", false)!,
48
+ zoomOffset: control.getDouble("zoom_offset", 0)!,
49
+ keepBuffer: control.getInt("keep_buffer", 2)!,
50
+ panBuffer: control.getInt("pan_buffer", 1)!,
51
+ tms: control.getBool("enable_tms", false)!,
52
+ tileBounds: parseLatLngBounds(control.get("tile_bounds")),
53
+ retinaMode: control.getBool("enable_retina_mode"),
54
+ maxZoom: control.getDouble("max_zoom", double.infinity)!,
55
+ minZoom: control.getDouble("min_zoom", 0)!,
56
+ evictErrorTileStrategy: parseEvictErrorTileStrategy(
57
+ control.getString("evict_error_tile_strategy"),
58
+ EvictErrorTileStrategy.none)!,
59
+ errorImage: errorImage,
60
+ errorTileCallback: (TileImage t, Object o, StackTrace? s) {
61
+ control.triggerEvent("image_error", o.toString());
62
+ },
63
+ additionalOptions: control.get("additional_options", {})!);
76
64
 
77
- return constrainedControl(context, tile, parent, control);
78
- });
65
+ return ConstrainedControl(control: control, child: tileLayer);
79
66
  }
80
67
  }
@@ -3,9 +3,7 @@ import 'package:flutter_map/flutter_map.dart';
3
3
 
4
4
  AttributionAlignment? parseAttributionAlignment(String? value,
5
5
  [AttributionAlignment? defValue]) {
6
- if (value == null) {
7
- return defValue;
8
- }
6
+ if (value == null) return defValue;
9
7
  return AttributionAlignment.values.firstWhereOrNull(
10
8
  (e) => e.name.toLowerCase() == value.toLowerCase()) ??
11
9
  defValue;