let AI comment everything because well... yeah...
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
// import 'package:fforte/screens/helper/snack_bar_helper.dart';
|
||||
// * Interactive map widget for camera trap location selection
|
||||
// * Features:
|
||||
// * - OpenStreetMap integration
|
||||
// * - Location marker placement
|
||||
// * - GPS coordinates display and saving
|
||||
// * - Localized interface
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:geolocator/geolocator.dart';
|
||||
@@ -6,11 +12,18 @@ import 'package:latlong2/latlong.dart';
|
||||
// import 'package:geocoding/geocoding.dart';
|
||||
import 'package:fforte/l10n/app_localizations.dart';
|
||||
|
||||
/// Widget for displaying and interacting with the map
|
||||
/// Allows users to select and save camera trap locations
|
||||
class Karte extends StatefulWidget {
|
||||
/// Controller for nearby location name
|
||||
final TextEditingController beiOrtC;
|
||||
/// Controller for location details
|
||||
final TextEditingController ortInfoC;
|
||||
/// Controller for longitude coordinate
|
||||
final TextEditingController decLngC;
|
||||
/// Controller for latitude coordinate
|
||||
final TextEditingController decLatC;
|
||||
/// Current GPS position
|
||||
final Position currentPosition;
|
||||
|
||||
const Karte(
|
||||
@@ -25,15 +38,20 @@ class Karte extends StatefulWidget {
|
||||
KarteState createState() => KarteState();
|
||||
}
|
||||
|
||||
/// State class for the map widget
|
||||
class KarteState extends State<Karte> {
|
||||
/// Current marker on the map
|
||||
Marker? currentMarker;
|
||||
/// Selected position coordinates
|
||||
LatLng? selectedPosition;
|
||||
/// Whether the save button should be visible
|
||||
bool saveVisible = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
// Initialize marker at current position
|
||||
currentMarker = Marker(
|
||||
point: LatLng(
|
||||
widget.currentPosition.latitude, widget.currentPosition.longitude),
|
||||
@@ -50,6 +68,7 @@ class KarteState extends State<Karte> {
|
||||
appBar: AppBar(
|
||||
title: Text(AppLocalizations.of(context)!.map),
|
||||
actions: [
|
||||
// Save location button
|
||||
Visibility(
|
||||
visible: saveVisible,
|
||||
child: Padding(
|
||||
@@ -76,6 +95,7 @@ class KarteState extends State<Karte> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Map display with OpenStreetMap tiles
|
||||
body: FlutterMap(
|
||||
mapController: MapController(),
|
||||
options: MapOptions(
|
||||
@@ -89,15 +109,21 @@ class KarteState extends State<Karte> {
|
||||
onTap: _handleTap,
|
||||
),
|
||||
children: [
|
||||
// OpenStreetMap tile layer
|
||||
TileLayer(
|
||||
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
userAgentPackageName: 'de.lupus.apps',
|
||||
),
|
||||
// Marker layer
|
||||
MarkerLayer(markers: [currentMarker!]),
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
/// Handle tap events on the map
|
||||
/// Creates a new marker at the tapped location
|
||||
/// @param position The tap position on the screen
|
||||
/// @param latlng The geographical coordinates of the tap
|
||||
_handleTap(TapPosition position, LatLng latlng) {
|
||||
setState(() {
|
||||
currentMarker = Marker(
|
||||
@@ -111,7 +137,7 @@ class KarteState extends State<Karte> {
|
||||
);
|
||||
// selectedPosition = latlng;
|
||||
saveVisible = true;
|
||||
});
|
||||
});
|
||||
// ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
// content: Text(
|
||||
// "${AppLocalizations.of(context)!.markerSet}\n${selectedPosition!.latitude}\n${selectedPosition!.longitude}")));
|
||||
|
||||
Reference in New Issue
Block a user