-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlayer.dart
More file actions
157 lines (146 loc) · 5.63 KB
/
layer.dart
File metadata and controls
157 lines (146 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
part of '../map.dart';
class MapLayerView extends StatefulWidget {
const MapLayerView({super.key});
@override
State<MapLayerView> createState() => _MapLayerViewState();
static double get reservedAttributionHeight => 100;
}
class _MapLayerViewState extends State<MapLayerView> with TickerProviderStateMixin {
late AnimatedMapController _mapController;
AppStore get store => LayrzState.store as AppStore;
List<MapLayer> get layers => store.availableLayers;
MapLayer? selectedLayer;
final ThemedMapController _controller = ThemedMapController();
final GlobalKey _mapKey = GlobalKey();
@override
void initState() {
super.initState();
_mapController = AnimatedMapController(
vsync: this,
duration: const Duration(seconds: 2),
);
_controller.addListener(_listener);
}
@override
void dispose() {
_mapController.dispose();
_controller.removeListener(_listener);
super.dispose();
}
void _listener(ThemedMapEvent event) {
debugPrint('layrz_theme_example/ThemedMapController() event: $event');
}
@override
Widget build(BuildContext context) {
return Layout(
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"Map Layers",
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
fontWeight: FontWeight.bold,
),
),
const SizedBox(height: 10),
Text(
"We uses flutter_map package to perform map operations. You can find more information about it "
"here: https://pub.dev/packages/flutter_map",
style: Theme.of(context).textTheme.bodyLarge,
maxLines: 8,
textAlign: TextAlign.justify,
),
Text(
"But, we also have different layers support for different map providers. So, how can we support all "
"of them? Easy! We create a wrapper! Only we provide a list of wrappers to a `ThemedMapLayer` widget "
"and automatically it will detect which one to use, of course the widget take the first one if the "
"default value is not provided, and automatically add the layer selector on the right-bottom corner "
"of the map. If you don't provide a list of layers, the widget will use the default one, which is "
"OpenStreetMap.",
style: Theme.of(context).textTheme.bodyLarge,
maxLines: 8,
textAlign: TextAlign.justify,
),
const SizedBox(height: 10),
ThemedButton(
labelText: 'PERFORMANCE TESTING',
onTap: () async {
debugPrint('Zooming in');
await _mapController.animatedZoomTo(8);
debugPrint("Waiting");
await Future.delayed(const Duration(seconds: 1));
debugPrint('Zooming out');
await _mapController.animatedZoomTo(13);
debugPrint("Waiting");
await Future.delayed(const Duration(seconds: 1));
debugPrint('Zooming in');
await _mapController.animatedZoomTo(8);
debugPrint("Waiting");
await Future.delayed(const Duration(seconds: 1));
debugPrint('Zooming out');
await _mapController.animatedZoomTo(13);
debugPrint("Done");
},
),
const SizedBox(height: 10),
Container(
decoration: generateContainerElevation(context: context),
height: 600,
clipBehavior: Clip.antiAlias,
child: FlutterMap(
key: _mapKey,
mapController: _mapController.mapController,
options: const MapOptions(
initialCenter: kGoldenMHeadquarters,
initialZoom: 13,
maxZoom: kMaxZoom,
minZoom: kMinZoom,
),
children: [
ThemedTileLayer(
layer: selectedLayer,
controller: _controller,
),
// MarkerLayer(
// markers: [
// Marker(
// point: t,
// width: 20,
// height: 20,
// child: Container(width: 20, height: 20, color: Colors.red),
// ),
// ],
// ),
// ThemedMapToolbar(
// layers: layers,
// selectedLayer: selectedLayer,
// onLayerChanged: (layer) => setState(() => selectedLayer = layer),
// enableGoogleStreetView: true,
// mapKey: _mapKey,
// additionalButtons: [
// ThemedMapButton(
// labelText: "My custom button",
// icon: Icons.house,
// onTap: () {
// debugPrint('My custom button');
// },
// ),
// ThemedMapButton(
// labelText: "Beurre Gatún",
// icon: Icons.abc,
// onTap: () {
// debugPrint('My custom button');
// },
// ),
// ],
// ),
],
),
),
],
),
),
);
}
}