diff --git a/src/views/oneMap/index.vue b/src/views/oneMap/index.vue index 66ef6ae..7b6487f 100644 --- a/src/views/oneMap/index.vue +++ b/src/views/oneMap/index.vue @@ -244,10 +244,11 @@ () => useSocket.chatMessage.value, (newVal, oldVal) => { console.log('更新---------', newVal); - + warningFeatures.value.push(newVal); //每次告警,加入到数组 + console.log('初步获取数据--', warningFeatures.value); // 添加告警点状态 // newVal.content.is_alarmOrder = false; // 默认没有告警 此时content返回的是对象 - showAlarm(newVal); + showAlarm(warningFeatures.value); // bus.emit('removeMapDatas', ['warning_monitor1']); // if (newVal.type == 'warnInfo') { @@ -295,40 +296,41 @@ // 地图预警点位展示 const showAlarm = val => { bus.emit('removeMapDatas', ['warning_monitor1']); - if (val.type == 'warnInfo') { - // 地图操作 - if (!val.content.length) return; - let warningFeatures = []; // 使用最外面定义的 warningFeatures.value 存储 - val.content.forEach(element => { - if (element.location) { - let warningFeature = turf.point(element.location.split(',').map(Number), element); - warningFeature.properties.name = element.assessment; - warningFeature.properties.size = 200; - warningFeatures.push(warningFeature); - } - }); - let warningFeaturesGeojson = turf.featureCollection(warningFeatures); - let key = 'warning_monitor1'; - bus.emit('getGeojsonByType', { - type: key, - callback: geojson => { - if (!!!geojson.features.length) bus.emit('setGeoJSON', { json: warningFeaturesGeojson, key: 'warning_monitor1' }); - bus.emit('setLayerVisible', { type: 'point', layername: key, isCheck: true }); - }, - }); - let warningPoint = newfiberMapbox.getLayers().filter(feature => feature.newfiberId == 'warning_monitor1')[0]; - if (warningPoint) { - warningPoint.on('click', e => { - let popupData = e.feature.properties; - console.log('popupData---', '告警12.19---------', popupData); - let data = { - title: popupData.wranLocation, - comIDs: ['gdpf'], - getSiteId: popupData.id, - }; - bus.emit('publicDialog', data); - }); + + // 地图操作 + if (!val.length) return; + let warningData = []; // 使用最外面定义的 warningFeatures.value 存储 + val.forEach(element => { + if (element.type != 'warnInfo') return; + if (element.is_alarmOrder && element.is_alarmOrder == true) return; + if (element.content.location) { + let warningFeature = turf.point(element.content.location.split(',').map(Number), element); + warningFeature.properties.name = element.content.assessment; + warningFeature.properties.size = 200; + warningData.push(warningFeature); } + }); + let warningFeaturesGeojson = turf.featureCollection(warningData); + let key = 'warning_monitor1'; + bus.emit('getGeojsonByType', { + type: key, + callback: geojson => { + if (!!!geojson.features.length) bus.emit('setGeoJSON', { json: warningFeaturesGeojson, key: 'warning_monitor1' }); + bus.emit('setLayerVisible', { type: 'point', layername: key, isCheck: true }); + }, + }); + let warningPoint = newfiberMapbox.getLayers().filter(feature => feature.newfiberId == 'warning_monitor1')[0]; + if (warningPoint) { + warningPoint.on('click', e => { + let popupData = e.feature.properties; + console.log('popupData---', '告警12.19---------', popupData); + let data = { + title: popupData.wranLocation, + comIDs: ['gdpf'], + getSiteId: popupData.id, + }; + bus.emit('publicDialog', data); + }); } }; @@ -338,7 +340,8 @@ if (item) { item.is_alarmOrder = true; } - + console.log(id, warningFeatures.value); + showAlarm(warningFeatures.value); // 更新地图渲染 };