Skip to content

Commit

Permalink
Added Google Tile layers
Browse files Browse the repository at this point in the history
  • Loading branch information
YarosMallorca committed Aug 20, 2024
1 parent bd8296b commit 1d166df
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 21 deletions.
55 changes: 46 additions & 9 deletions lib/layouts/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import 'package:url_launcher/url_launcher.dart';

import '../shared/aircraft_settings.dart';

enum MapLayer { streets, satellite }

class HomeLayout extends StatefulWidget {
const HomeLayout({super.key});

Expand All @@ -35,6 +37,8 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
final MapController mapController = MapController();
late final TabController _tabController;

late MapLayer _selectedMapLayer;

final List<Marker> _photoMarkers = [];

final _debounce = const Duration(milliseconds: 800);
Expand All @@ -47,6 +51,9 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
_tabController = TabController(length: 4, vsync: this);
_getLocationAndMoveMap();

_selectedMapLayer =
prefs.getInt("mapLayer") == 1 ? MapLayer.satellite : MapLayer.streets;

final presets = PresetManager.getPresets();
Provider.of<ValueListenables>(context, listen: false).selectedCameraPreset =
presets[0];
Expand Down Expand Up @@ -213,14 +220,16 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
),
children: [
TileLayer(
tileProvider: CancellableNetworkTileProvider(),
tileBuilder: Theme.of(context).brightness == Brightness.dark
? (context, tileWidget, tile) =>
darkModeTileBuilder(context, tileWidget, tile)
: null,
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.yarosfpv.dji_mapper',
),
tileProvider: CancellableNetworkTileProvider(),
tileBuilder: Theme.of(context).brightness == Brightness.dark
? (context, tileWidget, tile) =>
darkModeTileBuilder(context, tileWidget, tile)
: null,
urlTemplate: _selectedMapLayer == MapLayer.streets
? 'https://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}'
: 'https://{s}.google.com/vt/lyrs=y&x={x}&y={y}&z={z}',
userAgentPackageName: 'com.yarosfpv.dji_mapper',
subdomains: const ['mt0', 'mt1', 'mt2', 'mt3']),
PolygonLayer(polygons: [
Polygon(
points: listenables.polygon,
Expand Down Expand Up @@ -361,9 +370,37 @@ class _HomeLayoutState extends State<HomeLayout> with TickerProviderStateMixin {
),
Align(
alignment: Alignment.bottomRight,
child: Row(
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.end,
children: [
Material(
color: Theme.of(context).colorScheme.primaryContainer,
borderRadius: BorderRadius.circular(10),
child: InkWell(
borderRadius: BorderRadius.circular(10),
onTap: () => setState(() {
_selectedMapLayer =
_selectedMapLayer == MapLayer.streets
? MapLayer.satellite
: MapLayer.streets;
prefs.setInt(
"mapLayer",
_selectedMapLayer == MapLayer.streets
? 0
: 1);
}),
child: Padding(
padding: const EdgeInsets.all(8),
child: Icon(
Icons.layers,
size: 20,
color: Theme.of(context)
.colorScheme
.onPrimaryContainer,
),
)),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Material(
Expand Down
2 changes: 1 addition & 1 deletion macos/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Cocoa
import FlutterMacOS

@NSApplicationMain
@main
class AppDelegate: FlutterAppDelegate {
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true
Expand Down
8 changes: 4 additions & 4 deletions packages/litchi_waypoint_engine/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ packages:
dependency: transitive
description:
name: crypto
sha256: "1dceb0cf05cb63a7852c11560060e53ec2f182079a16ced6f4395c5b0875baf8"
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.0.5"
csv:
dependency: "direct main"
description:
Expand Down Expand Up @@ -346,10 +346,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand Down
12 changes: 6 additions & 6 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ packages:
dependency: transitive
description:
name: crypto
sha256: "1dceb0cf05cb63a7852c11560060e53ec2f182079a16ced6f4395c5b0875baf8"
sha256: ec30d999af904f33454ba22ed9a86162b35e52b44ac4807d1d93c288041d7d27
url: "https://pub.dev"
source: hosted
version: "3.0.4"
version: "3.0.5"
csslib:
dependency: transitive
description:
Expand Down Expand Up @@ -156,10 +156,10 @@ packages:
dependency: "direct main"
description:
name: file_picker
sha256: "1375f8685ca6f0412effecc2db834757e9d0e3e055468053e563794b0755cdcd"
sha256: "167bb619cdddaa10ef2907609feb8a79c16dfa479d3afaf960f8e223f754bf12"
url: "https://pub.dev"
source: hosted
version: "8.1.1"
version: "8.1.2"
fixnum:
dependency: transitive
description:
Expand Down Expand Up @@ -522,10 +522,10 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: c272f9cabca5a81adc9b0894381e9c1def363e980f960fa903c604c471b22f68
sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051"
url: "https://pub.dev"
source: hosted
version: "2.3.1"
version: "2.3.2"
shared_preferences_android:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: "Plan Survey & Photogrammetry Missions to use directly on your DJI

publish_to: "none"

version: 1.1.0+3
version: 1.2.0+4

environment:
sdk: ">=3.2.3 <4.0.0"
Expand Down

0 comments on commit 1d166df

Please sign in to comment.