Távolság vagy terület mérése a térképen terepbejárás nézetben
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:get/get.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:terepi_seged/enums/map_edit_tool.dart';
|
||||
import 'package:terepi_seged/enums/map_measure_type.dart';
|
||||
import 'package:terepi_seged/enums/map_survey_mode.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/controllers/map_survey_controller.dart';
|
||||
import 'package:terepi_seged/pages/map_survey/presentations/views/settings_dialog.dart';
|
||||
@@ -13,6 +14,7 @@ import 'package:terepi_seged/services/gnss/gnss_device_service.dart';
|
||||
import 'package:terepi_seged/services/gnss/gnss_service.dart';
|
||||
import 'package:terepi_seged/utils/rive_utils.dart';
|
||||
import 'package:terepi_seged/widgets/coordinate_panel.dart';
|
||||
import 'package:terepi_seged/widgets/map/distance_or_area_measure_layer.dart';
|
||||
import 'package:terepi_seged/widgets/map/imported_layer_overlay.dart';
|
||||
import 'package:terepi_seged/widgets/map/measure_bottom_panel.dart';
|
||||
import 'package:terepi_seged/widgets/map/note_item_label_layer.dart';
|
||||
@@ -66,6 +68,10 @@ class MapSurveyView extends GetView<MapSurveyController> {
|
||||
}
|
||||
},
|
||||
onTap: (tapPosition, point) {
|
||||
if (controller.isDistanceOrAreaMeasuring) {
|
||||
controller.addDistanceOrAreaMeasuredPoint(point);
|
||||
return;
|
||||
}
|
||||
if (controller.mode.value != MapSurveyMode.fieldWalk) return;
|
||||
if (controller.isMapEditing) return;
|
||||
final polygonHit = controller.polygonHitNotifier.value;
|
||||
@@ -233,6 +239,7 @@ class MapSurveyView extends GetView<MapSurveyController> {
|
||||
if (markers.isEmpty) return const SizedBox.shrink();
|
||||
return MarkerLayer(markers: markers);
|
||||
}),
|
||||
DistanceOrAreaMeasureLayer(controller: controller),
|
||||
Obx(() {
|
||||
final isGpsActive = GnssService.to.activeConnectionType.value !=
|
||||
GnssConnectionType.none;
|
||||
@@ -293,6 +300,41 @@ class MapSurveyView extends GetView<MapSurveyController> {
|
||||
right: 0,
|
||||
bottom: 0,
|
||||
child: MeasureBottomPanel(ctrl: controller));
|
||||
}),
|
||||
Obx(() {
|
||||
if (controller.mode.value != MapSurveyMode.fieldWalk)
|
||||
return SizedBox.shrink();
|
||||
return Positioned(
|
||||
right: 10,
|
||||
bottom: 300,
|
||||
child: Column(mainAxisSize: MainAxisSize.min, children: [
|
||||
// Távolság mérés
|
||||
_MeasureButton(
|
||||
icon: Icons.straighten,
|
||||
tooltip: 'Távolságmérés',
|
||||
active:
|
||||
controller.mapMeasureType.value == MapMeasureType.distance,
|
||||
onTap: controller.toggleMeasureDistance,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
// Területmérés
|
||||
_MeasureButton(
|
||||
icon: Icons.pentagon_outlined,
|
||||
tooltip: 'Területmérés',
|
||||
active: controller.mapMeasureType.value == MapMeasureType.area,
|
||||
onTap: controller.toggleMeasureArea,
|
||||
),
|
||||
// Visszavonás (ha van pont)
|
||||
if (controller.distanceOrAreaMeasurePoints.isNotEmpty) ...[
|
||||
const SizedBox(height: 4),
|
||||
_MeasureButton(
|
||||
icon: Icons.undo,
|
||||
tooltip: 'Utolsó pont törlése',
|
||||
active: false,
|
||||
onTap: controller.removeLastDistanceOrAreaMeasuredPoint,
|
||||
),
|
||||
]
|
||||
]));
|
||||
})
|
||||
// Positioned(top: 8, left: 0, right: 0, child: _ModeSelector()),
|
||||
// Positioned(
|
||||
@@ -579,3 +621,51 @@ class _DeltaCell extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _MeasureButton extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String tooltip;
|
||||
final bool active;
|
||||
final VoidCallback onTap;
|
||||
const _MeasureButton({
|
||||
required this.icon,
|
||||
required this.tooltip,
|
||||
required this.active,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
return Tooltip(
|
||||
message: tooltip,
|
||||
child: Material(
|
||||
color: active
|
||||
? Colors.deepOrange
|
||||
: isDark
|
||||
? Colors.grey.shade800.withOpacity(0.9)
|
||||
: Colors.white.withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
elevation: 3,
|
||||
shadowColor: Colors.black38,
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: onTap,
|
||||
child: SizedBox(
|
||||
width: 42,
|
||||
height: 42,
|
||||
child: Center(
|
||||
child: Icon(icon,
|
||||
size: 20,
|
||||
color: active
|
||||
? Colors.white
|
||||
: isDark
|
||||
? Colors.white70
|
||||
: Colors.black87),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user