Преглед изворни кода

fix:修改地图不出来bug

wangsisi пре 2 недеља
родитељ
комит
390688b294

+ 2 - 1
src/views/home/index.vue

@@ -163,7 +163,7 @@ onMounted(() => {
     homeMap.initMap("POINT(113.61448114737868 23.585550924763083)", mapRef.value);
     // homeMap.initMap(store.getters.userinfo.location, mapRef.value);
     // regionLayer = new RegionLayer(homeMap.kmap.map, currentFarm, currentRegion)
-    samplePointLayer = new SamplePointLayer(homeMap.kmap.map);
+    samplePointLayer = new SamplePointLayer(homeMap.kmap);
     blueRegionLayer = new BlueRegionLayer(homeMap.kmap);
 
     getYellow();
@@ -181,6 +181,7 @@ onUnmounted(() => {
 });
 
 const blueList = ref([]);
+// regionId: regionId.value
 const getBlueRegionList = (callback) => {
     VE_API.farm.blueRegionList({ farmId: organId.value, regionId: regionId.value }).then(({ data }) => {
         blueList.value = data.map((item) => {

+ 3 - 1
src/views/home/map/blueRegionLayer.js

@@ -29,7 +29,9 @@ class BlueRegionLayer {
                 feature.setStyle(this.vectorStyle.getPolygonStyle(item.color+opacity, strokeColor, 1));
                 this.blueRegionLayer.addFeature(feature);
             }
-            this.kmap.fit(this.blueRegionLayer.source.getExtent(), {padding:[100,100,100,100]});
+            setTimeout(()=>{
+                this.kmap.fit(this.blueRegionLayer.source.getExtent(), {padding:[100,100,100,100]});
+            })
         }
     }
 

+ 4 - 0
src/views/home/map/samplePointLayer.js

@@ -28,6 +28,7 @@ class SamplePointLayer {
       distance: 15,
       minDistance: 60,
     });
+    this.mapRef = map
 
     this.curPoint = null
     this.curArea = null
@@ -104,6 +105,9 @@ class SamplePointLayer {
         features: features,
       });
       that.clusterSource.setSource(source)
+      setTimeout(()=>{
+        that.mapRef.fit(this.treeClusterLayer.source.getExtent(), {padding:[100,100,100,100]})
+      })
     })
   }