- TopNavBar: Nominatim geocoding search field plus Home (center on first waypoint) and Fit (zoom to mission bounds) buttons (HTML prototype: #searchWrap/#homeBtn/#fitBtn). Both show a SnackBar instead of doing nothing when there are no waypoints yet. - Renders as its own bar just below TopModeBar rather than fused into the same pill: TopModeBar lives in AppShell, a layer above PlanScreen, which owns the MapController these actions actually need. Fusing them would need lifting the MapController to shared state - reasonable follow-up if pixel-fidelity with the prototype's single bar matters later, but not necessary for the functionality itself. - Replaced SimpleAttributionWidget with a compact custom attribution: OSM's tile usage policy requires visible attribution to stay, so instead of removing it (as first asked) I shrank it and dropped the "flutter_map |" prefix per the user's follow-up choice, so it reads cleanly against the now-opaque bottom bar instead of looking like a second banner. Added 5 tests (nav bar renders, home/fit SnackBars with no waypoints, empty search is a no-op). All 26 tests and flutter analyze pass. Verified on the Pixel_10a emulator: searched "Berlin" and confirmed the map flew there, dropped a waypoint, panned far away, and confirmed Home re-centers and snaps onto it exactly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
110 lines
3.6 KiB
Dart
110 lines
3.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_map/flutter_map.dart';
|
|
import 'package:latlong2/latlong.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
import '../../domain/mission/route_geometry.dart';
|
|
|
|
/// Vollbild-OSM-Karte, entspricht dem Leaflet-`#map` im HTML-Demonstrator:
|
|
/// randlos, ohne Zoom-Buttons (Pinch-to-Zoom/Pan reicht), Standard-OSM-Tiles.
|
|
class MissionMap extends StatelessWidget {
|
|
const MissionMap({
|
|
super.key,
|
|
this.mapController,
|
|
this.waypointMarkers = const [],
|
|
this.routeSegments = const [],
|
|
this.rubberBandLine,
|
|
this.onMapReady,
|
|
});
|
|
|
|
final MapController? mapController;
|
|
|
|
/// Kreis-Marker fuer die Wegpunkte der aktuellen Mission (Doku 3.7).
|
|
final List<CircleMarker> waypointMarkers;
|
|
|
|
/// Geraden + Kreisbogen-Segmente des Flugpfads (Doku 3.7/4.6); rot
|
|
/// markierte Segmente ueberschreiten Steig-/Sinkrate oder Kurvenradius.
|
|
final List<RouteSegment> routeSegments;
|
|
|
|
/// Gestrichelte Vorschaulinie vom letzten Wegpunkt zur aktuellen
|
|
/// Kartenmitte, waehrend noch kein neuer Punkt bestaetigt wurde.
|
|
final List<LatLng>? rubberBandLine;
|
|
|
|
final VoidCallback? onMapReady;
|
|
|
|
// Default-Zentrum/Zoom uebernommen aus dem HTML-Demonstrator
|
|
// (Drone Mission Control.html: L.map(...).setView([52.3676, 4.9041], 16)).
|
|
static const _initialCenter = LatLng(52.3676, 4.9041);
|
|
static const _initialZoom = 16.0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return FlutterMap(
|
|
mapController: mapController,
|
|
options: MapOptions(
|
|
initialCenter: _initialCenter,
|
|
initialZoom: _initialZoom,
|
|
minZoom: 3,
|
|
maxZoom: 19,
|
|
onMapReady: onMapReady,
|
|
),
|
|
children: [
|
|
TileLayer(
|
|
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
userAgentPackageName: 'de.dmc.dmc_app',
|
|
maxZoom: 19,
|
|
),
|
|
PolylineLayer(
|
|
polylines: [
|
|
for (final segment in routeSegments)
|
|
Polyline(
|
|
points: segment.points,
|
|
strokeWidth: 3,
|
|
color: segment.bad ? const Color(0xFFE2574A) : Colors.white,
|
|
),
|
|
if (rubberBandLine != null)
|
|
Polyline(
|
|
points: rubberBandLine!,
|
|
strokeWidth: 2,
|
|
color: Colors.white.withValues(alpha: 0.55),
|
|
pattern: StrokePattern.dashed(segments: const [6.0, 6.0]),
|
|
),
|
|
],
|
|
),
|
|
CircleLayer(circles: waypointMarkers),
|
|
const _CompactAttribution(),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Schlanke Pflicht-Attribution fuer die OSM-Kacheln (Tile Usage Policy) -
|
|
/// bewusst ohne den "flutter_map |"-Praefix von SimpleAttributionWidget und
|
|
/// dezenter gestaltet, damit sie nicht wie ein zweiter Balken ueber der
|
|
/// Bottom-Bar wirkt. Bleibt sichtbar und antippbar, da die Policy sichtbare
|
|
/// Namensnennung verlangt.
|
|
class _CompactAttribution extends StatelessWidget {
|
|
const _CompactAttribution();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SafeArea(
|
|
child: Align(
|
|
alignment: Alignment.bottomLeft,
|
|
child: GestureDetector(
|
|
onTap: () =>
|
|
launchUrl(Uri.parse('https://www.openstreetmap.org/copyright')),
|
|
child: Container(
|
|
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
|
color: Colors.white.withValues(alpha: 0.5),
|
|
child: const Text(
|
|
'© OpenStreetMap contributors',
|
|
style: TextStyle(fontSize: 9, color: Colors.black87),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|