From 7c40e28b5287efad97e4a158522b620811febba4 Mon Sep 17 00:00:00 2001
From: fangyuan <527392886@qq.com>
Date: 星期四, 15 十二月 2022 16:42:12 +0800
Subject: [PATCH] 地图组件及趋势分析页面修改

---
 src/components/map/index.vue |   99 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 78 insertions(+), 21 deletions(-)

diff --git a/src/components/map/index.vue b/src/components/map/index.vue
index 4a6f839..a39ac2e 100644
--- a/src/components/map/index.vue
+++ b/src/components/map/index.vue
@@ -1,32 +1,89 @@
 <template>
-    <div id="container"></div>
+  <div id="container"></div>
 </template>
 <script>
 import AMapLoader from "@amap/amap-jsapi-loader";
 export default {
-    data() {
-        return {
-            map: null,
+  data() {
+    return {
+      map: null,
+      _point: { x: "119.27179890", y: "28.59027084" },
+      _zoom: 15,
+    };
+  },
+  created() {
+    debugger
+    // if (this.point) {
+    //   this._point = this.point;
+    // }
+    // if (this.zoom) {
+    //   this._zoom = this.zoom;
+    // }
+  },
+  methods: {
+    locationMap() {
+      const that = this;
+      debugger
+      setTimeout(() => {
+        // console.log("_zoom---", that.zoom);
+        // console.log("_point---", JSON.stringify(that.point));
+        that.map.setZoomAndCenter(that._zoom, [that.point.x, that.point.y]);
+        if (that.mark) {
+          // 鍒涘缓涓�涓� Marker 瀹炰緥锛�
+          var marker = new AMap.Marker({
+            position: new AMap.LngLat(that._point.x, that._point.y), // 缁忕含搴﹀璞★紝涔熷彲浠ユ槸缁忕含搴︽瀯鎴愮殑涓�缁存暟缁刐116.39, 39.9]
+            title: that.mark.title,
+          });
+
+          // 灏嗗垱寤虹殑鐐规爣璁版坊鍔犲埌宸叉湁鐨勫湴鍥惧疄渚嬶細
+          that.map.add(marker);
         }
+      }, 1000);
     },
-    mounted() {
-        AMapLoader.load({
-            key: "091ade377d4db40f68cc78cb9658ce8d", // 鐢宠濂界殑Web绔紑鍙戣�匥ey锛岄娆¤皟鐢� load 鏃跺繀濉�
-            version: "2.0", // 鎸囧畾瑕佸姞杞界殑 JSAPI 鐨勭増鏈紝缂虹渷鏃堕粯璁や负 1.4.15
-            plugins: [], // 闇�瑕佷娇鐢ㄧ殑鐨勬彃浠跺垪琛紝濡傛瘮渚嬪昂'AMap.Scale'绛�
-        })
-            .then((AMap) => {
-                this.map = new AMap.Map("container");
-            })
-            .catch((e) => {
-                console.log(e);
-            });
-    }
-}
+  },
+  mounted() {
+    const that = this;
+    AMapLoader.load({
+      key: "091ade377d4db40f68cc78cb9658ce8d", // 鐢宠濂界殑Web绔紑鍙戣�匥ey锛岄娆¤皟鐢� load 鏃跺繀濉�
+      version: "2.0", // 鎸囧畾瑕佸姞杞界殑 JSAPI 鐨勭増鏈紝缂虹渷鏃堕粯璁や负 1.4.15
+      plugins: [], // 闇�瑕佷娇鐢ㄧ殑鐨勬彃浠跺垪琛紝濡傛瘮渚嬪昂'AMap.Scale'绛�
+    })
+      .then((AMap) => {
+        that.map = new AMap.Map("container");
+        that.locationMap();
+      })
+      .catch((e) => {
+        console.log(e);
+      });
+    // const that = this;
+    // debugger
+    // that.map.setZoomAndCenter(that._zoom, [that._point.x, that._point.y]);
+    // if (that.mark) {
+    //   // 鍒涘缓涓�涓� Marker 瀹炰緥锛�
+    //   var marker = new AMap.Marker({
+    //     position: new AMap.LngLat(that._point.x, that._point.y), // 缁忕含搴﹀璞★紝涔熷彲浠ユ槸缁忕含搴︽瀯鎴愮殑涓�缁存暟缁刐116.39, 39.9]
+    //     title: that.mark.title,
+    //   });
+
+    //   // 灏嗗垱寤虹殑鐐规爣璁版坊鍔犲埌宸叉湁鐨勫湴鍥惧疄渚嬶細
+    //   that.map.add(marker);
+    // }
+  },
+  watch: {
+    point(newval, oldval) {
+      this._point = newval;
+      this.locationMap();
+    },
+    zoom(newval, oldval) {
+      this._zoom = newval;
+    },
+  },
+  props: ["point", "zoom", "mark"],
+};
 </script>
 <style lang="scss" scoped>
 #container {
-    width: 100%;
-    height: 100%;
+  width: 100%;
+  height: 100%;
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0