打点优化

This commit is contained in:
mmc
2026-02-25 20:36:46 +08:00
parent 4d3872b576
commit 0b936f50aa
3 changed files with 137 additions and 22 deletions

View File

@@ -6,6 +6,8 @@ import 'package:geolocator/geolocator.dart';
import 'package:latlong2/latlong.dart';
import 'package:maibu_satabot_v2/features/home/presentation/widgets/BottomDirectionLine.dart';
import 'package:maibu_satabot_v2/features/home/presentation/widgets/common/enum.dart';
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/CenterLocation.dart';
import 'package:maibu_satabot_v2/features/home/presentation/widgets/map/HeadingPointer.dart';
import 'package:maibu_satabot_v2/features/home/presentation/widgets/startpoint_area.dart';
import '../path_list_pages.dart';
@@ -33,6 +35,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// ========== 核心新增状态 ==========
List<LatLng> _markedPoints = []; // 存储所有打点坐标
LatLng get _mapCenter => _mapController.center; // 实时获取地图中心坐标
double _headingAngle = 0.0; // 航向角(单位:度)
// =================================
@override
@@ -150,18 +153,26 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
),
/// ========== 新增:中心标与历史打点的虚线连线 ==========
///
/// if (_markedPoints.length >= 2)
PolylineLayer(
polylines: [
for (int i = 0; i < _markedPoints.length - 1; i++)
Polyline(
points: [_markedPoints[i], _markedPoints[i + 1]],
color: Colors.orange.withOpacity(0.5),
strokeWidth: 1.5,
),
],
),
if (_markedPoints.isNotEmpty)
PolylineLayer(
polylines: [
for (var point in _markedPoints)
Polyline(
points: [_mapCenter, point], // 中心标 ↔ 历史打点
color: Colors.orange.withOpacity(
0.5,
), // 降低透明度,模拟虚线视觉效果
strokeWidth: 1.5, // 调细一点,更接近虚线
// 去掉 dashArray,直接用实线
),
Polyline(
points: [_mapCenter, _markedPoints.last],
color: Colors.blue.withOpacity(0.5),
strokeWidth: 1.5,
),
],
),
@@ -171,12 +182,13 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
markers: [
Marker(
point: _currentLatLng!,
width: 20,
height: 20,
child: const Icon(
Icons.my_location,
color: Colors.blue,
size: 30,
width: 40,
height: 40,
child: CustomPaint(
size: const Size(40, 40),
painter: HeadingMarkerPainter(
headingAngle: _headingAngle,
),
),
),
],
@@ -195,6 +207,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 8), // 向下偏移8px(抵消默认的顶部对齐)
// 绿色打点标记
Container(
width: 16,
@@ -226,21 +239,22 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
),
/// ========== 核心:地图正中心固定定位标 ==========
const Positioned(
Positioned(
left: 0,
right: 0,
top: 0,
bottom: 0,
child: Center(
child: Icon(
Icons.location_pin, // 定位标图标
color: Colors.red, // 红色醒目
size: 30,
shadows: [BoxShadow(color: Colors.white, blurRadius: 2)],
// 自定义十字标(中心精准对齐地图中心)
child: SizedBox(
width: 16, // 十字整体宽度
height: 16, // 十字整体高度
child: CustomPaint(
painter: CrosshairPainter(), // 自定义十字画笔
),
),
),
),
// 右侧悬浮菜单
Positioned(
height: 336,