reghao před 2 roky
rodič
revize
624a3bdf6c
1 změnil soubory, kde provedl 37 přidání a 21 odebrání
  1. 37 21
      src/views/home/BdMap.vue

+ 37 - 21
src/views/home/BdMap.vue

@@ -2,10 +2,10 @@
   <div>
     <label>
       <el-select v-model="form" placeholder="选择标签" @change="onChange">
-        <el-option label="内容1" value="1" />
-        <el-option label="内容2" value="2" />
-        <el-option label="内容3" value="3" />
-        <el-option label="内容4" value="4" />
+        <el-option label="分类1" value="1" />
+        <el-option label="分类2" value="2" />
+        <el-option label="分类3" value="3" />
+        <el-option label="分类4" value="4" />
       </el-select>
     </label>
     <!-- zoom=7 的比例尺为 100km   -->
@@ -104,7 +104,7 @@ export default {
         lat: null,
         lng: null
       },
-      form: null,
+      form: 1,
     }
   },
   created() {
@@ -129,22 +129,33 @@ export default {
         })
 
         const type = 1
-        getMapMarkers(type).then(res => {
-          if (res.code === 0) {
-            this.markers = res.data
-          } else {
-            this.$notify({
-              title: res.status,
-              message: res.data,
-              type: 'warning',
-              duration: 500
-            })
-          }
-        }).catch(error => {
-            this.$message.error(error.message)
-          })
+        this.getMapMarkersWrapper(type)
       }
     },
+    getMapMarkersWrapper(type) {
+      getMapMarkers(type).then(res => {
+        if (res.code === 0) {
+          this.$notify({
+            message: '加载了 ' + res.data.length + ' 条数据',
+            type: 'warning',
+            duration: 3000
+          })
+          this.markers = res.data
+        } else {
+          this.$notify({
+            message: res.msg,
+            type: 'warning',
+            duration: 3000
+          })
+        }
+      }).catch(error => {
+        this.$notify({
+          message: error.message,
+          type: 'warning',
+          duration: 3000
+        })
+      })
+    },
     getClickInfo(e) {
       //console.log(e)
       // 调整地图中心位置
@@ -211,10 +222,15 @@ export default {
       })
     },
     onCopyError(e) {
-      console.log('复制失败!')
+      this.$notify({
+        message: '复制 GoogleEarth 坐标失败!',
+        type: 'error',
+        duration: 3000
+      })
     },
     onChange() {
-      console.log(this.form)
+      const type = this.form
+      this.getMapMarkersWrapper(type)
     }
   }
 }