added map tab in view cams

This commit is contained in:
nico
2024-05-01 19:29:32 +02:00
parent 3894d9aefe
commit de7ff75fd6
4 changed files with 62 additions and 27 deletions

View File

@@ -1,5 +1,4 @@
todo:
sandorte ansehen in karte (extra tab)
Platzierung garnix als standart aber pflichtfeld
fix send file to server
im englischen abändern
@@ -10,6 +9,7 @@ eintrg in db wenn http response (in sent column)
not to do:
sandorte ansehen in karte (extra tab)
einzelnen eintrag löschen
zurückfeld in datenansicht
maybe auch vorschläge aus templates in dropdown menüs anzeigen

View File

@@ -140,11 +140,6 @@ class _VarTextFieldState extends State<VarTextField> {
],
);
}
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
value: item,
child: Text(item),
);
}
// Karte
@@ -166,9 +161,7 @@ class Karte extends StatefulWidget {
}
class KarteState extends State<Karte> {
List<Marker> markers = [
const Marker(point: LatLng(0, 0), child: Icon(Icons.location_on))
];
List<Marker> markers = [ ];
LatLng? selectedPosition;
Position? updatedPosition;
bool saveVisible = false;

View File

@@ -1,10 +1,10 @@
import 'package:fforte/addCam/add_cam_main.dart';
import 'package:fforte/other/db_helper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:flutter_slidable/flutter_slidable.dart';
import 'package:latlong2/latlong.dart';
// * Site that shows all entries in the databases
class ViewCams extends StatefulWidget {
@@ -18,6 +18,7 @@ class _ViewCamsState extends State<ViewCams> {
// var declaration
late Future<List<Map<String, dynamic>>> place;
late Future<List<Map<String, dynamic>>> templates;
late List<Marker> markers;
// loads the entries
@override
@@ -106,14 +107,13 @@ class _ViewCamsState extends State<ViewCams> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(tabs: [
Tab(text: AppLocalizations.of(context)!.completed),
Tab(
text: AppLocalizations.of(context)!.uncompleted,
)
Tab(text: AppLocalizations.of(context)!.uncompleted,),
Tab(text: AppLocalizations.of(context)!.map,),
]),
title: Text(AppLocalizations.of(context)!.viewplacesappbar)),
body: TabBarView(
@@ -137,17 +137,20 @@ class _ViewCamsState extends State<ViewCams> {
),
body: Column(
children: [
const SizedBox(height: 10,),
const SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
const SizedBox(width: 10,),
const SizedBox(
width: 10,
),
Text(
style: const TextStyle(
decoration: TextDecoration.underline
),
decoration: TextDecoration.underline),
AppLocalizations.of(context)!.placedata),
],
),
@@ -155,10 +158,11 @@ class _ViewCamsState extends State<ViewCams> {
children: [
Text(
style: const TextStyle(
decoration: TextDecoration.underline
),
decoration: TextDecoration.underline),
AppLocalizations.of(context)!.sent),
const SizedBox(width: 10,),
const SizedBox(
width: 10,
),
],
),
],
@@ -260,6 +264,44 @@ class _ViewCamsState extends State<ViewCams> {
),
);
}
}),
FutureBuilder(
future: place,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
} else if (snapshot.hasError) {
return Text("Error ${snapshot.error}");
} else {
List<Map<String, dynamic>> place = snapshot.data!;
markers = snapshot.data!.map((e) {
return Marker(
width: 80.0,
height: 80.0,
point: LatLng(double.parse(e['DECLAT'].toString()), double.parse(e['DECLNG'].toString())),
child: Column(
children: [
const Icon(Icons.location_on, color: Colors.red,),
Text("ID: ${e['ID'].toString()}", style: const TextStyle(color: Colors.black),)
],
));
}).toList();
return FlutterMap(
options: MapOptions(
initialCenter: markers.isEmpty ? const LatLng(50, 10) : markers.first.point,
interactionOptions: const InteractionOptions(
flags: InteractiveFlag.pinchZoom |
InteractiveFlag.drag |
InteractiveFlag.pinchMove)),
children: [
TileLayer(
urlTemplate:
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
MarkerLayer(markers: markers)
]);
}
})
],
)),