From 3465ac6e980f1473e4f42ba3eaafc7815423efec Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 27 十一月 2021 17:10:45 +0800
Subject: [PATCH] 功能完善

---
 lib/utils/map_util.dart |   32 ++++++++++++++++++++------------
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/lib/utils/map_util.dart b/lib/utils/map_util.dart
index e858bd3..5db3152 100644
--- a/lib/utils/map_util.dart
+++ b/lib/utils/map_util.dart
@@ -12,9 +12,9 @@
   ///鐢荤嚎
   ///https://lbs.baidu.com/index.php?title=flutter/loc/render-map/ployline
   ///https://mapopen-pub-androidsdk.bj.bcebos.com/map/flutter/docs/utils_api_1.2/flutter_baidu_mapapi_utils/flutter_baidu_mapapi_utils-library.html
-  static drawLine(List<BMFCoordinate> points, Color lineColor,
+  static Future drawLine(List<BMFCoordinate> points, Color lineColor,
       BMFMapController? _mapController,
-      {int width = 16}) {
+      {int width = 16}) async {
     List<Color> colors = [lineColor];
     List<int> indexs = List.filled(points.length - 1, 0);
 
@@ -28,19 +28,23 @@
         lineDashType: BMFLineDashType.LineDashTypeNone,
         lineCapType: BMFLineCapType.LineCapRound,
         lineJoinType: BMFLineJoinType.LineJoinRound);
-    _mapController?.addPolyline(colorsPolyline);
+    await _mapController?.addPolyline(colorsPolyline);
   }
 
   //鑾峰彇鍦板浘鐨勬樉绀哄弬鏁�
   static Future<MapShowInfo> getMapShowParams(
       List<BMFCoordinate> points) async {
-    List<double?> outSides = _getOutSidePoint(points);
-    BMFCoordinate center = BMFCoordinate(
-        (outSides[0]! + outSides[1]!) / 2, (outSides[2]! + outSides[3]!) / 2);
-    //鐣�1/20鐨勮竟鐣�
-    int zoom =
-        await _getZoom(outSides[0], outSides[1], outSides[2], outSides[3]);
-    return MapShowInfo(center, zoom);
+    if (points.length == 1) {
+      return MapShowInfo(points[0], 18);
+    } else {
+      List<double?> outSides = _getOutSidePoint(points);
+      BMFCoordinate center = BMFCoordinate(
+          (outSides[0]! + outSides[1]!) / 2, (outSides[2]! + outSides[3]!) / 2);
+      //鐣�1/20鐨勮竟鐣�
+      int zoom =
+          await _getZoom(outSides[0], outSides[1], outSides[2], outSides[3]);
+      return MapShowInfo(center, zoom);
+    }
   }
 
   //
@@ -136,6 +140,11 @@
   static cleanAllMarkers(BMFMapController? _mapController) {
     _mapController!.cleanAllMarkers();
   }
+
+  static Future<double?> getDistance(
+      BMFCoordinate pointA, BMFCoordinate pointB) async {
+    return await BMFCalculateUtils.getLocationDistance(pointA, pointB);
+  }
 }
 
 ///璺緞褰曞埗绠$悊
@@ -161,8 +170,7 @@
     positionList.add(currentPosition);
 
     //鐢昏捣濮嬬偣
-    MapMarkerUtil.addTravelStartMarker(
-        mapController, currentPosition!)
+    MapMarkerUtil.addTravelStartMarker(mapController, currentPosition!)
         .then((value) {
       startMarkers = value;
     });

--
Gitblit v1.8.0