From febb0babbb08e2ad0eaa8a28ec4591d922da1065 Mon Sep 17 00:00:00 2001
From: zhongrj <123456>
Date: Wed, 28 Dec 2022 16:53:47 +0800
Subject: [PATCH] 安保活动备案新增活动人员,车辆按钮页面

---
 src/components/map/mapBox.vue |   24 ++++++++++++++++++------
 1 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/src/components/map/mapBox.vue b/src/components/map/mapBox.vue
index 19e92a8..872acff 100644
--- a/src/components/map/mapBox.vue
+++ b/src/components/map/mapBox.vue
@@ -4,7 +4,7 @@
       <div style="position: absolute;right:40%;top:-1%;z-index: 999999">
         <p style="margin-top: 10px" v-if="!isDetail">
           <el-button type="primary" size="small" @click="point()">绘制路线</el-button>
-          <el-button type="danger" size="small" @click="clearDraw()">重置</el-button>
+          <el-button  size="small" @click="clearDraw()">重置</el-button>
         </p>
       </div>
       <!--画线后的提示-->
@@ -32,7 +32,7 @@
 
 export default {
   name: 'mapBox',
-  props:['routeRange','isDetail',"pointLonLat"],
+  props:['routeRange','isDetail'],
   data() {
     return {
       map: null,
@@ -94,8 +94,8 @@
       })
       _this.map.addLayer(_this.lineVector)
       _this.map.addLayer(_this.pointVector)
-      _this.addLineDraw(_this.routeRange)
-      _this.addPoint(_this.pointLonLat)
+      //在地图上回显线或点
+      _this.startAdd(_this.routeRange)
     },
     // 绘画之后的样式
     styleFunction() {
@@ -146,10 +146,15 @@
     },
     // 添加点
     addPoint(pointLonLat){
+      // pointLonLat = POINT(115.87531914674 28.8603307485585)
       if (pointLonLat){
+        let pointData = ""
+        let pointArray = []
+        pointData = pointLonLat.match(/\(([^)]*)\)/);
+        pointArray = pointData[1].split(" ")
         //设置点
         let feature_Point = new Feature({
-          geometry: new Point([Number(pointLonLat.lon), Number(pointLonLat.lat)])
+          geometry: new Point([Number(pointArray[0]), Number(pointArray[1])])
         })
         //点样式
         let style = new Style({
@@ -162,7 +167,7 @@
         });
         feature_Point.setStyle(style);
         this.pointVector.getSource().addFeature(feature_Point);
-        let center = [Number(pointLonLat.lon), Number(pointLonLat.lat)];
+        let center = [Number(pointArray[0]), Number(pointArray[1])];
         let view = this.map.getView();
         view.setZoom(16);
         view.animate({
@@ -392,6 +397,13 @@
       _this.tipPosition.w = x + n;
       _this.tipPosition.h = y + m;
     },
+    startAdd(routeRange){
+      if (routeRange.startsWith("LINESTRING")){
+        this.addLineDraw(routeRange)
+      }else {
+        this.addPoint(routeRange)
+      }
+    }
   },
   mounted() {
     this.createMap()

--
Gitblit v1.9.3