Sfoglia il codice sorgente

地图选址组件完善入库合回填地图

yangfan 2 mesi fa
parent
commit
04f62b721b
1 ha cambiato i file con 13 aggiunte e 11 eliminazioni
  1. 13 11
      src/components/Generator/components/JNPFMap/index.vue

+ 13 - 11
src/components/Generator/components/JNPFMap/index.vue

@@ -101,6 +101,17 @@ export default {
   },
   async mounted() {
     await loadJS('https://api.tianditu.gov.cn/api?v=4.0&tk=a4dc3ba4fde4085083ab82395af6c046')
+    if (this.$attrs.expandMode) {
+      setTimeout(() => {
+        const lon = this.value.split(this.$attrs.keepSeparator)[0]
+        const lat = this.value.split(this.$attrs.keepSeparator)[1]
+        const map1 = new T.Map('mapDiv1')
+        map1.centerAndZoom(new T.LngLat(lon, lat), zoom)
+        marker = new T.Marker(new T.LngLat(lon, lat))
+        //向地图上添加标注
+        map1.addOverLay(marker)
+      }, 500)
+    }
   },
   watch: {
     isShow(val) {
@@ -111,6 +122,8 @@ export default {
             const lat = this.innerValue.split(this.$attrs.keepSeparator)[1]
             this.mapObject.lon = lon
             this.mapObject.lat = lat
+
+            console.log(lon, lat)
           }
           if (!map) {
             map = new T.Map('mapDiv')
@@ -144,17 +157,6 @@ export default {
     innerValue(val) {
       val && this.$emit('change', val)
       if (val) {
-        if (this.$attrs.expandMode) {
-          setTimeout(() => {
-            const lon = val.split(this.$attrs.keepSeparator)[0]
-            const lat = val.split(this.$attrs.keepSeparator)[1]
-            const map1 = new T.Map('mapDiv1')
-            map1.centerAndZoom(new T.LngLat(lon, lat), zoom)
-            marker = new T.Marker(new T.LngLat(lon, lat))
-            //向地图上添加标注
-            map1.addOverLay(marker)
-          }, 500)
-        }
       }
     },
     value(val) {