Browse Source

增加环路设置途经点时的地址逆解析,保证分布图里查看环路详情时候显示各个节点的中文地址

yanglzh 2 years ago
parent
commit
833eebb100

+ 14 - 19
src/views/heating/heatStation/loop/component/edit.vue

@@ -133,6 +133,7 @@ export default defineComponent({
   setup(prop, { emit }) {
     let map: any = null
     let BMapGL: any = null
+    let myGeo: any = null
     let polyline: any = null
     let startDraw = false
     let stationInfo: any = null
@@ -285,7 +286,7 @@ export default defineComponent({
             sort: index + 1,
             lnt: item.lng,
             lat: item.lat,
-            // position: item.position
+            position: item.position
           }))
           if (params.id) {
             //修改
@@ -345,6 +346,7 @@ export default defineComponent({
 
     const initMap = () => {
       BMapGL = (window as any).BMapGL
+      myGeo = new BMapGL.Geocoder()
       map = new BMapGL.Map("loop-map-container");
       // 116.404, 39.915
       const point = new BMapGL.Point(124.383044, 40.124296);
@@ -355,26 +357,19 @@ export default defineComponent({
       map.addControl(zoomCtrl);
       map.addControl(cityCtrl);
 
-      // state.mapLocal = new BMapGL.LocalSearch(map, {
-      //   renderOptions: { map: map }
-      // })
-
       map.addEventListener('click', ({ latlng }: any) => {
         if (!startDraw) return
-
-        state.pointList.push(latlng)
-
-        let marker = new BMapGL.Marker(latlng);
-        // 在地图上添加点标记
-        map.addOverlay(marker);
-        setLine(state.pointList)
-
-        // let myGeo = new BMapGL.Geocoder
-        // myGeo.getLocation(new BMapGL.Point(point.lng, point.lat), (result: any) => {
-        //   if (result) {
-        //     state.pointList[index].position = result.address
-        //   }
-        // })
+        // 获取地址名称
+        myGeo.getLocation(latlng, (result: any) => {
+          if (result) {
+            // console.log(result.address)
+            state.pointList.push({ ...latlng, position: result.address })
+            let marker = new BMapGL.Marker(latlng);
+            // 在地图上添加点标记
+            map.addOverlay(marker);
+            setLine(state.pointList)
+          }
+        })
       })
     }
     function setLine(pointList: any[]) {

+ 2 - 2
src/views/heating/monitor/map.vue

@@ -28,12 +28,12 @@
             </div>
           </div>
           <div class="view-div-content">
-            <!-- <div>路线信息</div>
+            <div>路线信息</div>
             <div class="mt-1 pl-4">
               <p v-for="(point, index) in item.loopViaPointInfo" :key="index">
                 {{ point.position }}
               </p>
-            </div> -->
+            </div>
             <div class="mt-1">实时温度</div>
             <el-table :data="[{
 							outTemperature1: item.outTemperature1,