Navigációs térkép és útvoanlrögzítés hibáinak javítása
This commit is contained in:
@@ -10,7 +10,9 @@ import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_map/flutter_map.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:latlong2/latlong.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:terepi_seged/enums/layer_import_source_type.dart';
|
||||
@@ -300,10 +302,11 @@ class LayerImportService extends GetxService {
|
||||
defaultPolygonBorderColor: const Color(0xCC1565C0),
|
||||
defaultPolygonBorderStroke: 1.5,
|
||||
defaultPolygonIsFilled: true,
|
||||
markerCreationCallback: _pointMarkerWithLabel,
|
||||
onMarkerTapCallback: (props) {
|
||||
final label = props['name'] ?? props['title'] ?? '';
|
||||
if (label.toString().isNotEmpty) {
|
||||
Get.snackbar(label.toString(), props['description']?.toString() ?? '',
|
||||
final label = _extractFeatureName(props);
|
||||
if (label != null) {
|
||||
Get.snackbar(label, props['description']?.toString() ?? '',
|
||||
snackPosition: SnackPosition.BOTTOM,
|
||||
duration: const Duration(seconds: 3));
|
||||
}
|
||||
@@ -323,6 +326,71 @@ class LayerImportService extends GetxService {
|
||||
);
|
||||
}
|
||||
|
||||
// ── Rugalmas névkinyerés — az attribútum neve forrásonként eltérhet ──
|
||||
|
||||
static const _nameKeys = [
|
||||
'name',
|
||||
'nev',
|
||||
'név',
|
||||
'label',
|
||||
'title',
|
||||
'megnevezes',
|
||||
'megnevezés',
|
||||
'ref',
|
||||
'point'
|
||||
];
|
||||
|
||||
/// A properties-ből megpróbál egy "nevet" kinyerni, a kulcs pontos
|
||||
/// nevétől (kis/nagybetű) függetlenül, több elterjedt változatot is
|
||||
/// figyelembe véve. Null, ha semelyik ismert kulcs alatt nincs
|
||||
/// érdemi (nem üres) érték.
|
||||
static String? _extractFeatureName(Map<String, dynamic> properties) {
|
||||
final lower = {
|
||||
for (final e in properties.entries) e.key.toLowerCase(): e.value,
|
||||
};
|
||||
for (final key in _nameKeys) {
|
||||
final v = lower[key];
|
||||
if (v != null && v.toString().trim().isNotEmpty) {
|
||||
return v.toString().trim();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Pont-marker, ami — ha talál nevet az attribútumok közt — egy kis
|
||||
/// feliratot is mutat a jelölő fölött, nem csak koppintásra.
|
||||
static Marker _pointMarkerWithLabel(
|
||||
LatLng point, Map<String, dynamic> properties) {
|
||||
final label = _extractFeatureName(properties);
|
||||
return Marker(
|
||||
point: point,
|
||||
width: 100,
|
||||
height: 46,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (label != null)
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 1),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white.withOpacity(0.9),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
border: Border.all(color: Colors.red.withOpacity(0.7)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style:
|
||||
const TextStyle(fontSize: 10, fontWeight: FontWeight.w600),
|
||||
),
|
||||
),
|
||||
const Icon(Icons.location_pin, color: Colors.red, size: 26),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
LayerImportSourceType _sourceType(String ext) => switch (ext.toLowerCase()) {
|
||||
'kml' => LayerImportSourceType.kml,
|
||||
'kmz' => LayerImportSourceType.kmz,
|
||||
|
||||
Reference in New Issue
Block a user