From d42f54925e7371e8741d7d8ae059e044461455ed Mon Sep 17 00:00:00 2001 From: Sara <sarasdj@stud.ntnu.no> Date: Mon, 19 Feb 2024 16:04:56 +0100 Subject: [PATCH] upate: random OSM map location for testing, SatLayer --- app/lib/pages/widgets/map_widget.dart | 23 ++++-- app/lib/pages/widgets/osm_map.dart | 2 +- app/lib/pages/widgets/sat_layer.dart | 29 +++++++ app/pubspec.lock | 113 +++++++++++++++++++++++++- app/pubspec.yaml | 1 + 5 files changed, 160 insertions(+), 8 deletions(-) diff --git a/app/lib/pages/widgets/map_widget.dart b/app/lib/pages/widgets/map_widget.dart index 5d5d154e..847b9a9e 100644 --- a/app/lib/pages/widgets/map_widget.dart +++ b/app/lib/pages/widgets/map_widget.dart @@ -1,11 +1,10 @@ import 'package:flutter/material.dart'; import '../marker_handler/marker_data.dart'; import '../consts.dart'; -import 'package:flutter_map/flutter_map.dart'; -import 'package:latlong2/latlong.dart'; import 'quick_view_chart.dart'; import 'stat_charts.dart'; import 'osm_map.dart'; +import 'sat_layer.dart'; class MapContainerWidget extends StatefulWidget { final List<Measurement> markerList; @@ -44,6 +43,19 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { height: screenWidth * boxHeight, child: OSMmap(markerList: widget.markerList), // OpenStreetMap layer ), + SizedBox( + width: screenWidth * boxWidth, + height: screenWidth * boxHeight, + child: Stack( + children: [ + SatLayer(markerList: widget.markerList), // Satellite layer + Visibility( + visible: satLayer, // Only show layer if satellite button is toggled on + child: SatLayer(markerList: widget.markerList), + ), + ], + ), + ), Positioned( // Quick view box layered over map bottom: 10, right: 10, @@ -55,7 +67,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { color: Colors.blue.withOpacity(0.7), child: Stack( children: [ - Visibility( // Content only visible when box is maximized + Visibility( // Graph only visible when box is maximized and a marker is selected visible: !isMinimized && selectedMarker != null, child: Center( child: Padding( @@ -63,7 +75,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { child: SizedBox( width: (screenWidth * boxWidth) / 2.3, height: (screenWidth * boxWidth) / 2.3, - child: const QuickViewChart(), + child: const QuickViewChart(), // Quick view graph ), ), ), @@ -85,7 +97,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { ), ), ), - Positioned( + Positioned( // Satellite button top: 10, right: 10, child: GestureDetector( @@ -93,6 +105,7 @@ class _MapContainerWidgetState extends State<MapContainerWidget> { setState(() { satLayer = !satLayer; // Toggle satellite layer state on press }); + print("satLayer? : $satLayer"); }, child: Container( padding: const EdgeInsets.all(8), diff --git a/app/lib/pages/widgets/osm_map.dart b/app/lib/pages/widgets/osm_map.dart index 46174748..3e8eeeb2 100644 --- a/app/lib/pages/widgets/osm_map.dart +++ b/app/lib/pages/widgets/osm_map.dart @@ -31,7 +31,7 @@ class OSMmap extends StatelessWidget { // Map corner coordinates to LatLng objects return LatLng(corner.latitude, corner.longitude); }).toList(), - /*onTap: () { + /*onTap: () { NB: figure out how to make polygons interactive setState(() { selectedMarker = measurement; }); diff --git a/app/lib/pages/widgets/sat_layer.dart b/app/lib/pages/widgets/sat_layer.dart index e69de29b..f5663b5e 100644 --- a/app/lib/pages/widgets/sat_layer.dart +++ b/app/lib/pages/widgets/sat_layer.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import '../marker_handler/marker_data.dart'; +import 'package:flutter_map/flutter_map.dart'; +import 'package:latlong2/latlong.dart'; + +class SatLayer extends StatelessWidget { + final List<Measurement> markerList; + + const SatLayer({ + Key? key, + required this.markerList, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return FlutterMap( + options: MapOptions( + center: LatLng(31.0274,89.0065), // NB: random location in Tibet for testing purposes + zoom: 9.0, + ), + children: [ + TileLayer( // Map from OpenStreetMap + urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + subdomains: const ['a', 'b', 'c'], + ), + ], + ); + } +} diff --git a/app/pubspec.lock b/app/pubspec.lock index 98e04063..1551ab20 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -49,6 +49,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + csslib: + dependency: transitive + description: + name: csslib + sha256: "706b5707578e0c1b4b7550f64078f0a0f19dec3f50a178ffae7006b0a9ca58fb" + url: "https://pub.dev" + source: hosted + version: "1.0.0" equatable: dependency: transitive description: @@ -102,11 +110,24 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_plugin_android_lifecycle: + dependency: transitive + description: + name: flutter_plugin_android_lifecycle + sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da + url: "https://pub.dev" + source: hosted + version: "2.0.17" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" google_fonts: dependency: "direct main" description: @@ -115,6 +136,62 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.4" + google_maps: + dependency: transitive + description: + name: google_maps + sha256: "555d5d736339b0478e821167ac521c810d7b51c3b2734e6802a9f046b64ea37a" + url: "https://pub.dev" + source: hosted + version: "6.3.0" + google_maps_flutter: + dependency: "direct main" + description: + name: google_maps_flutter + sha256: ae66fef3e71261d7df2eff29b2a119e190b2884325ecaa55321b1e17b5504066 + url: "https://pub.dev" + source: hosted + version: "2.5.3" + google_maps_flutter_android: + dependency: transitive + description: + name: google_maps_flutter_android + sha256: "714530f865f13bb3b9505c58821c3baed5d247a871724acf5d2ea5808fbed02c" + url: "https://pub.dev" + source: hosted + version: "2.6.2" + google_maps_flutter_ios: + dependency: transitive + description: + name: google_maps_flutter_ios + sha256: "29503b5159da2308a66212c3827963998bfb943ba073e2114fb2d486b47fd2c8" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + google_maps_flutter_platform_interface: + dependency: transitive + description: + name: google_maps_flutter_platform_interface + sha256: "6060779f020638a8eedeb0fb14234818e5fa32ec45a4653d6428ab436e2bbc64" + url: "https://pub.dev" + source: hosted + version: "2.4.3" + google_maps_flutter_web: + dependency: transitive + description: + name: google_maps_flutter_web + sha256: "6245721c160d6f531c1ef568cf9bef8d660cd585a982aa75121269030163785a" + url: "https://pub.dev" + source: hosted + version: "0.5.4+3" + html: + dependency: transitive + description: + name: html + sha256: "3a7812d5bcd2894edf53dfaf8cd640876cf6cef50a8f238745c8b8120ea74d3a" + url: "https://pub.dev" + source: hosted + version: "0.15.4" http: dependency: "direct main" description: @@ -139,6 +216,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.19.0" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + js_wrapping: + dependency: transitive + description: + name: js_wrapping + sha256: e385980f7c76a8c1c9a560dfb623b890975841542471eade630b2871d243851c + url: "https://pub.dev" + source: hosted + version: "0.7.4" latlong2: dependency: "direct main" description: @@ -323,6 +416,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.0.0" + sanitize_html: + dependency: transitive + description: + name: sanitize_html + sha256: "12669c4a913688a26555323fb9cec373d8f9fbe091f2d01c40c723b33caa8989" + url: "https://pub.dev" + source: hosted + version: "2.1.0" sky_engine: dependency: transitive description: flutter @@ -352,6 +453,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + stream_transform: + dependency: transitive + description: + name: stream_transform + sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f" + url: "https://pub.dev" + source: hosted + version: "2.1.0" string_scanner: dependency: transitive description: @@ -441,5 +550,5 @@ packages: source: hosted version: "1.0.4" sdks: - dart: ">=3.2.0 <4.0.0" - flutter: ">=3.10.0" + dart: ">=3.2.3 <4.0.0" + flutter: ">=3.16.6" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index 804a5c15..04ffc04f 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -15,6 +15,7 @@ dependencies: provider: ^5.0.0 fl_chart: ^0.20.0-nullsafety1 google_fonts: any + google_maps_flutter: ^2.0.12 -- GitLab