@@ -24,6 +24,8 @@ import 'package:url_launcher/url_launcher.dart';
24
24
25
25
import '../shared/aircraft_settings.dart' ;
26
26
27
+ enum MapLayer { streets, satellite }
28
+
27
29
class HomeLayout extends StatefulWidget {
28
30
const HomeLayout ({super .key});
29
31
@@ -35,6 +37,8 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
35
37
final MapController mapController = MapController ();
36
38
late final TabController _tabController;
37
39
40
+ late MapLayer _selectedMapLayer;
41
+
38
42
final List <Marker > _photoMarkers = [];
39
43
40
44
final _debounce = const Duration (milliseconds: 800 );
@@ -47,6 +51,9 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
47
51
_tabController = TabController (length: 4 , vsync: this );
48
52
_getLocationAndMoveMap ();
49
53
54
+ _selectedMapLayer =
55
+ prefs.getInt ("mapLayer" ) == 1 ? MapLayer .satellite : MapLayer .streets;
56
+
50
57
final presets = PresetManager .getPresets ();
51
58
Provider .of <ValueListenables >(context, listen: false ).selectedCameraPreset =
52
59
presets[0 ];
@@ -213,14 +220,16 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
213
220
),
214
221
children: [
215
222
TileLayer (
216
- tileProvider: CancellableNetworkTileProvider (),
217
- tileBuilder: Theme .of (context).brightness == Brightness .dark
218
- ? (context, tileWidget, tile) =>
219
- darkModeTileBuilder (context, tileWidget, tile)
220
- : null ,
221
- urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png' ,
222
- userAgentPackageName: 'com.yarosfpv.dji_mapper' ,
223
- ),
223
+ tileProvider: CancellableNetworkTileProvider (),
224
+ tileBuilder: Theme .of (context).brightness == Brightness .dark
225
+ ? (context, tileWidget, tile) =>
226
+ darkModeTileBuilder (context, tileWidget, tile)
227
+ : null ,
228
+ urlTemplate: _selectedMapLayer == MapLayer .streets
229
+ ? 'https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}'
230
+ : 'https://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}' ,
231
+ userAgentPackageName: 'com.yarosfpv.dji_mapper' ,
232
+ subdomains: const ['mt0' , 'mt1' , 'mt2' , 'mt3' ]),
224
233
PolygonLayer (polygons: [
225
234
Polygon (
226
235
points: listenables.polygon,
@@ -361,9 +370,37 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
361
370
),
362
371
Align (
363
372
alignment: Alignment .bottomRight,
364
- child: Row (
373
+ child: Column (
365
374
mainAxisSize: MainAxisSize .min,
375
+ mainAxisAlignment: MainAxisAlignment .end,
366
376
children: [
377
+ Material (
378
+ color: Theme .of (context).colorScheme.primaryContainer,
379
+ borderRadius: BorderRadius .circular (10 ),
380
+ child: InkWell (
381
+ borderRadius: BorderRadius .circular (10 ),
382
+ onTap: () => setState (() {
383
+ _selectedMapLayer =
384
+ _selectedMapLayer == MapLayer .streets
385
+ ? MapLayer .satellite
386
+ : MapLayer .streets;
387
+ prefs.setInt (
388
+ "mapLayer" ,
389
+ _selectedMapLayer == MapLayer .streets
390
+ ? 0
391
+ : 1 );
392
+ }),
393
+ child: Padding (
394
+ padding: const EdgeInsets .all (8 ),
395
+ child: Icon (
396
+ Icons .layers,
397
+ size: 20 ,
398
+ color: Theme .of (context)
399
+ .colorScheme
400
+ .onPrimaryContainer,
401
+ ),
402
+ )),
403
+ ),
367
404
Padding (
368
405
padding: const EdgeInsets .all (8.0 ),
369
406
child: Material (
0 commit comments