Explorar el Código

聚合卡顿问题

彭宇 hace 2 años
padre
commit
1b9e1b85ab
Se han modificado 2 ficheros con 17 adiciones y 13 borrados
  1. 5 7
      src/components/supermap.vue
  2. 12 6
      src/views/forest.vue

+ 5 - 7
src/components/supermap.vue

@@ -584,7 +584,6 @@ export default {
         if (this.isAggregationMyGroup != undefined && this.isAggregationMyGroup != false) {
           this.isAggregationMyGroup.clearLayers()
         }
-        if (this.isAggregationLayers != null && this.isAggregationLayers.length > 0) {
           this.map.removeLayer(this.isAggregationLayers)
           this.isAggregationLayers = []
           this.radiusLayers = []
@@ -598,11 +597,11 @@ export default {
             //最大缩放级别点击聚合图标展开图标
             spiderfyOnMaxZoom: true
           })
-        }
       } else {
         if (this.myGroup != undefined && this.myGroup != false) {
           this.myGroup.clearLayers()
         }
+        this.map.removeLayer(this.layers)
         this.layers = []
       }
     },
@@ -974,7 +973,7 @@ export default {
         })
         let markerClick = window.L.marker([markersList[i].lat, markersList[i].lng], {
           icon: icon
-        }).addTo(this.map)
+        })
         if (markersList[i].bindPopupHtml != null && markersList[i].bindPopupHtml !== '') {
           let html = markersList[i].bindPopupHtml
           if (keepBindPopup) {
@@ -1008,14 +1007,13 @@ export default {
         if (isAggregation) {
           _that.isAggregationLayers.addLayer(markerClick)
           _that.isAggregationMyGroup = window.L.layerGroup(_that.isAggregationLayers)
-          this.map.addLayer(_that.isAggregationLayers)
         } else {
           _that.layers.push(markerClick)
           _that.myGroup = window.L.layerGroup(_that.layers)
-          this.map.addLayer(_that.myGroup)
         }
-
       }
+      this.map.addLayer(_that.isAggregationLayers)
+      this.map.addLayer(_that.myGroup)
     },
     setMarkersByType: function(markersList, type) { //地图标点(根据类型,可取消落点 clearMByType方法)
       const _that = this
@@ -1266,7 +1264,7 @@ export default {
 		align-items: center;
 		.input-group-addon{
 			color: $inBlue;
-			
+
 		}
 		.form-control{
 			padding: 0 .3rem;

+ 12 - 6
src/views/forest.vue

@@ -559,27 +559,30 @@ export default {
             keepBindPopup: false,
             isAggregation: false
           }
-          if (this.eventList.length > 50) {
+          if (this.eventList.length > 200) {
             markersMap.isAggregation = true
           }
           if (this.eventList[i].eventStatusValue == 'forest_event_status_1' && this.eventList[i].urgeCount == 0) {
             markersMap.click = 'showEventDialog'
             markersMap.icon = 'sj-icon-map-xinshangbao'
-            markersMap.isAggregation = false
+            markersMap.isAggregation = true
           }
           if (this.eventList[i].eventStatusValue == 'forest_event_status_1' && this.eventList[i].urgeCount > 0) {
             markersMap.click = 'showEventDialog'
             markersMap.icon = 'sj-icon-map-cuiban'
-            markersMap.isAggregation = false
+            markersMap.isAggregation = true
           } else if (this.eventList[i].eventStatusValue == 'forest_event_status_2') {
             markersMap.click = 'showEventDialog'
             markersMap.icon = 'sj-icon-map-qianshou'
+            markersMap.isAggregation = false
           } else if (this.eventList[i].eventStatusValue == 'forest_event_status_5') {
             markersMap.click = 'showEventDialog'
             markersMap.icon = 'sj-icon-map-banjie'
+            markersMap.isAggregation = false
           } else if (this.eventList[i].eventStatusValue == 'forest_event_status_6') {
             markersMap.click = 'showEventDialog'
             markersMap.icon = 'sj-icon-map-guidang'
+            markersMap.isAggregation = true
           }
           markersMap.parameter = this.eventList[i].eventCode
           markersMap.lng = this.eventList[i].longitude
@@ -918,27 +921,30 @@ export default {
               keepBindPopup: false,
               isAggregation: false
             }
-            if (this.eventList.length > 50) {
+            if (this.eventList.length > 200) {
               markersMap.isAggregation = true
             }
             if (this.eventList[i].eventStatusValue == 'forest_event_status_1' && this.eventList[i].urgeCount == 0) {
               markersMap.click = 'showEventDialog'
               markersMap.icon = 'sj-icon-map-xinshangbao'
-              markersMap.isAggregation = false
+              markersMap.isAggregation = true
             }
             if (this.eventList[i].eventStatusValue == 'forest_event_status_1' && this.eventList[i].urgeCount > 0) {
               markersMap.click = 'showEventDialog'
               markersMap.icon = 'sj-icon-map-cuiban'
-              markersMap.isAggregation = false
+              markersMap.isAggregation = true
             } else if (this.eventList[i].eventStatusValue == 'forest_event_status_2') {
               markersMap.click = 'showEventDialog'
               markersMap.icon = 'sj-icon-map-qianshou'
+              markersMap.isAggregation = false
             } else if (this.eventList[i].eventStatusValue == 'forest_event_status_5') {
               markersMap.click = 'showEventDialog'
               markersMap.icon = 'sj-icon-map-banjie'
+              markersMap.isAggregation = false
             } else if (this.eventList[i].eventStatusValue == 'forest_event_status_6') {
               markersMap.click = 'showEventDialog'
               markersMap.icon = 'sj-icon-map-guidang'
+              markersMap.isAggregation = true
             }
             markersMap.parameter = this.eventList[i].eventCode
             markersMap.lng = this.eventList[i].longitude