浏览代码

事件点位 双击需要可定位 也可输入经纬度

王通 1 年之前
父节点
当前提交
c07cb05239
共有 2 个文件被更改,包括 53 次插入60 次删除
  1. 19 25
      src/components/eventLocation.vue
  2. 34 35
      src/components/supermap.vue

+ 19 - 25
src/components/eventLocation.vue

@@ -29,9 +29,6 @@
                       <div class="bgt-img">
                         <img v-if="item.picturePath!=null&&item.picturePath!=''" :src="item.picturePath"
                              style="width: 93px;height: 64px"/>
-                        <img v-else-if="item.eventType == '510'"
-                             src="../assets/images/水压.png"
-                             style="width: 93px;height: 64px"/>
                         <img v-else src="../assets/images/integrated/event-img-sub.png"
                              style="width: 93px;height: 64px"/>
                       </div>
@@ -115,8 +112,9 @@
             <eventLocationSupermap ref="eventLocationSupermap" style="width: 100%;height: 51vh;"
                                    :mapDiv="'eventLocationMap'" :mapSite="{doubleClickZoom:false,zoom:8}"
                                    :codes="['9fa5']"
-                                   :isSideBySide="false" @preview="preview"
+                                   :isSideBySide="false"  @preview="preview"
                                    @showEventDialog="showEventDialog"></eventLocationSupermap>
+            <!--            :showLatLng="showLatLng"-->
           </div>
         </div>
       </div>
@@ -285,7 +283,11 @@ export default {
     /** ----------------------------------摄像头预览结束------------------------------------- */
   },
   methods: {
-    getCurrentDataStr() {
+    showLatLng(lat, lng) {
+      this.longitude=lng
+      this.latitude=lat
+    },
+    getCurrentDataStr(){
       let date = new Date()
       let y = date.getFullYear()
       let m = date.getMonth() + 1
@@ -295,6 +297,8 @@ export default {
       return y + '-' + m + '-' + d
     },
     cancelEventLocationShow() {
+      this.longitude=""
+      this.latitude=""
       if (this.oWebControl != null) {
         this.oWebControl.JS_HideWnd()   // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
         this.oWebControl.JS_Disconnect().then(function() {  // 断开与插件服务连接成功
@@ -316,6 +320,7 @@ export default {
         return
       }
       this.activeName = 'event'
+      this.$refs.eventLocationSupermap.dropLocation(this.latitude,this.longitude,10)
       let marker = [{
         lng: this.longitude,
         lat: this.latitude,
@@ -404,18 +409,16 @@ export default {
             markersMap.bindPopupHtml += '</div>'
             that.markersList.push(markersMap)
           }
-          setTimeout(() => {
-            that.$refs.eventLocationSupermap.clearM(false)
-            that.$refs.eventLocationSupermap.clearM(true)
-            that.$refs.eventLocationSupermap.setMarkers(that.markersList)
-            that.$refs.eventLocationSupermap.setMarkers(marker)
-          }, 1000)
+          that.$refs.eventLocationSupermap.clearM(false)
+          that.$refs.eventLocationSupermap.clearM(true)
+          that.$refs.eventLocationSupermap.clearP()
+          that.$refs.eventLocationSupermap.setMarkers(that.markersList)
+          that.$refs.eventLocationSupermap.setMarkers(marker)
         } else {
-          setTimeout(() => {
-            that.$refs.eventLocationSupermap.clearM(false)
-            that.$refs.eventLocationSupermap.clearM(true)
-            that.$refs.eventLocationSupermap.setMarkers(marker)
-          }, 1000)
+          that.$refs.eventLocationSupermap.clearM(false)
+          that.$refs.eventLocationSupermap.clearM(true)
+          that.$refs.eventLocationSupermap.clearP()
+          that.$refs.eventLocationSupermap.setMarkers(marker)
         }
       })
     },
@@ -590,15 +593,6 @@ export default {
     alertReinstall: function() {
       this.$modal.msgWarning('请重新安装客户端')
     },
-    cancelEventLocationShow() {
-      if (this.oWebControl != null) {
-        this.oWebControl.JS_HideWnd()   // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
-        this.oWebControl.JS_Disconnect().then(function() {  // 断开与插件服务连接成功
-          },
-          function() {  // 断开与插件服务连接失败
-          })
-      }
-    },
     /** 预览按钮操作 */
     preview(cameraParam) {
       this.showTVWall(cameraParam.code, cameraParam.name);

+ 34 - 35
src/components/supermap.vue

@@ -716,12 +716,11 @@ export default {
         spiderfyOnMaxZoom: true
       })
       if (!isSideBySide) { //只有一个地图
-        if (this.codes.length != 1) {
+        if (_that.codes.length != 1) {
           modal.msgError('请输入一个地图code!')
           return
         }
-        getSuperMap(this.codes).then(resp => {
-
+        getSuperMap(_that.codes).then(resp => {
           let mapList = resp.data
           if (mapList != null && mapList.length > 0) {
             let url = mapList[0].url
@@ -752,10 +751,10 @@ export default {
               logoControl: logoControl
             }
             let loadConfiguration = Object.assign(defaultConfigure, mapSite)
-            this.map = window.L.map(this.mapDiv, loadConfiguration)
+            _that.map = window.L.map(_that.mapDiv, loadConfiguration)
 
             //鼠标双击落点
-            if (this.showLatLng != undefined) {
+            if (_that.showLatLng != undefined) {
               let icon = new window.L.Icon({
                 iconUrl: iconList['marker'],
                 iconSize: [48, 48],
@@ -764,21 +763,21 @@ export default {
                 shadowSize: [41, 41]
               })
 
-              this.map.on('dblclick', function(e) {
+              _that.map.on('dblclick', function(e) {
                 _that.clearP()
                 _that.showLatLng(e.latlng.lat, e.latlng.lng)
                 let marker = window.L.marker([e.latlng.lat, e.latlng.lng], {
                   icon: icon
-                }).addTo(this.map)
+                }).addTo(_that.map)
                 _that.latLngLayers.push(marker)
                 _that.latLngGroup = window.L.layerGroup(_that.latLngLayers)
-                this.map.addLayer(_that.latLngGroup)
+                _that.map.addLayer(_that.latLngGroup)
               })
             }
             //鼠标绘制区域
-            if (this.showAreaLatLng != undefined) {
+            if (_that.showAreaLatLng != undefined) {
               var editableLayers = new window.L.FeatureGroup()
-              this.map.addLayer(editableLayers)
+              _that.map.addLayer(editableLayers)
               let options = {
                 position: 'topleft',
                 draw: {
@@ -796,8 +795,8 @@ export default {
                 }
               }
               var drawControl = new window.L.Control.Draw(options)
-              this.map.addControl(drawControl)
-              this.map.on(window.L.Draw.Event.CREATED, function(e) {
+              _that.map.addControl(drawControl)
+              _that.map.on(window.L.Draw.Event.CREATED, function(e) {
                 let editableLayer = e.layer
                 let layerType = e.layerType
                 editableLayer.on('dblclick', function(e) {
@@ -811,9 +810,9 @@ export default {
               })
             }
             //鼠标绘制线段
-            if (this.showLineLatLng != undefined) {
+            if (_that.showLineLatLng != undefined) {
               var editableLayers = new window.L.FeatureGroup()
-              this.map.addLayer(editableLayers)
+              _that.map.addLayer(editableLayers)
               let options = {
                 position: 'topleft',
                 draw: {
@@ -831,8 +830,8 @@ export default {
                 }
               }
               var drawControl = new window.L.Control.Draw(options)
-              this.map.addControl(drawControl)
-              this.map.on(window.L.Draw.Event.CREATED, function(e) {
+              _that.map.addControl(drawControl)
+              _that.map.on(window.L.Draw.Event.CREATED, function(e) {
                 let editableLayer = e.layer
                 let layerType = e.layerType
                 editableLayer.on('dblclick', function(e) {
@@ -846,15 +845,15 @@ export default {
             }
             // url = 'https://iserver.supermap.io/iserver/services/map-china400/rest/maps/China_4326'
 
-            window.L.supermap.tiledMapLayer(url).addTo(this.map)
+            window.L.supermap.tiledMapLayer(url).addTo(_that.map)
           }
         })
       } else { //卷帘地图
-        if (this.codes.length != 2) {
+        if (_that.codes.length != 2) {
           modal.msgError('请输入两个地图code!')
           return
         }
-        getSuperMap(this.codes).then(resp => {
+        getSuperMap(_that.codes).then(resp => {
           let mapList = resp.data
           if (mapList != null && mapList.length == 2) {
             let stamenurl = mapList[0].url
@@ -887,9 +886,9 @@ export default {
             }
 
             let loadConfiguration = Object.assign(defaultConfigure, mapSite)
-            this.map = window.L.map(this.mapDiv, loadConfiguration)
+            _that.map = window.L.map(_that.mapDiv, loadConfiguration)
             //鼠标双击落点
-            if (this.showLatLng != undefined) {
+            if (_that.showLatLng != undefined) {
               let icon = new window.L.Icon({
                 iconUrl: iconList['marker'],
                 iconSize: [48, 48],
@@ -898,21 +897,21 @@ export default {
                 shadowSize: [41, 41]
               })
 
-              this.map.on('dblclick', function(e) {
+              _that.map.on('dblclick', function(e) {
                 _that.clearP()
                 _that.showLatLng(e.latlng.lat, e.latlng.lng)
                 let marker = window.L.marker([e.latlng.lat, e.latlng.lng], {
                   icon: icon
-                }).addTo(this.map)
+                }).addTo(_that.map)
                 _that.latLngLayers.push(marker)
                 _that.latLngGroup = window.L.layerGroup(_that.latLngLayers)
-                this.map.addLayer(_that.latLngGroup)
+                _that.map.addLayer(_that.latLngGroup)
               })
             }
             //鼠标绘制区域
-            if (this.showAreaLatLng != undefined) {
+            if (_that.showAreaLatLng != undefined) {
               var editableLayers = new window.L.FeatureGroup()
-              this.map.addLayer(editableLayers)
+              _that.map.addLayer(editableLayers)
               let options = {
                 position: 'topleft',
                 draw: {
@@ -930,8 +929,8 @@ export default {
                 }
               }
               var drawControl = new window.L.Control.Draw(options)
-              this.map.addControl(drawControl)
-              this.map.on(window.L.Draw.Event.CREATED, function(e) {
+              _that.map.addControl(drawControl)
+              _that.map.on(window.L.Draw.Event.CREATED, function(e) {
                 let editableLayer = e.layer
                 let layerType = e.layerType
                 editableLayer.on('dblclick', function(e) {
@@ -945,9 +944,9 @@ export default {
               })
             }
             //鼠标绘制线段
-            if (this.showLineLatLng != undefined) {
+            if (_that.showLineLatLng != undefined) {
               var editableLayers = new window.L.FeatureGroup()
-              this.map.addLayer(editableLayers)
+              _that.map.addLayer(editableLayers)
               let options = {
                 position: 'topleft',
                 draw: {
@@ -965,8 +964,8 @@ export default {
                 }
               }
               var drawControl = new window.L.Control.Draw(options)
-              this.map.addControl(drawControl)
-              this.map.on(window.L.Draw.Event.CREATED, function(e) {
+              _that.map.addControl(drawControl)
+              _that.map.on(window.L.Draw.Event.CREATED, function(e) {
                 let editableLayer = e.layer
                 let layerType = e.layerType
                 editableLayer.on('dblclick', function(e) {
@@ -979,9 +978,9 @@ export default {
               })
             }
 
-            let stamenLayer = window.L.supermap.tiledMapLayer(stamenurl).addTo(this.map)
-            let osmLayer = window.L.supermap.tiledMapLayer(osmurl).addTo(this.map)
-            L.control.sideBySide(stamenLayer, osmLayer).addTo(this.map)
+            let stamenLayer = window.L.supermap.tiledMapLayer(stamenurl).addTo(_that.map)
+            let osmLayer = window.L.supermap.tiledMapLayer(osmurl).addTo(_that.map)
+            L.control.sideBySide(stamenLayer, osmLayer).addTo(_that.map)
           }
         })
       }