diff --git a/hd-glasses-app/src/assets/map/icon_paishuibeng_h.png b/hd-glasses-app/src/assets/map/icon_paishuibeng_h.png new file mode 100644 index 0000000..81b1743 Binary files /dev/null and b/hd-glasses-app/src/assets/map/icon_paishuibeng_h.png differ diff --git a/hd-glasses-app/src/pages/hd_map.vue b/hd-glasses-app/src/pages/hd_map.vue index abb09aa..782dae7 100644 --- a/hd-glasses-app/src/pages/hd_map.vue +++ b/hd-glasses-app/src/pages/hd_map.vue @@ -311,15 +311,6 @@ export default { } this.selectPoint = coordinate; this.coordinate = coordinate; - console.log(JSON.stringify(this.coordinate)) - if (Object.keys(this.pointLayer).length == 0) { - // 创建图层 - this.pointLayer = new VectorLayer({ - source: new VectorSource(), - }); - // 图层添加到地图上 - this.map.addLayer(this.pointLayer); - } // 创建feature要素,一个feature就是一个点坐标信息 const feature = new Feature({ @@ -483,8 +474,8 @@ export default { if (res.status == 200) { res.data.result.records.map(record => { try { - if (record.leastLocation.length > 0) { - this.map.removeInteraction(record.leastLocation, "equipment") + if (record.leastLocation!=null) { + this.addPointWidthCoordinate(record.leastLocation, "equipment") } } catch (e) { console.error(e) @@ -504,8 +495,8 @@ export default { if (res.status == 200) { res.data.result.records.map(record => { try { - if (record.location.length > 0) { - this.map.removeInteraction(record.location, "alarm") + if (record.location!=null) { + this.addPointWidthCoordinate(record.location, "alarm") } } catch (e) { console.error(e) @@ -519,7 +510,76 @@ export default { location.href = "uniwebview://action?function=switchBigScreen" }, addPointWidthCoordinate(coordinate, type) { - console.log("addPointWidthCoordinate", type, coordinate) + coordinate=coordinate.split(",") + if(type=='alarm'){ + console.log("addPointWidthCoordinate", type, coordinate) + if (Object.keys(this.alarmLayer).length == 0) { + // 创建图层 + this.alarmLayer = new VectorLayer({ + source: new VectorSource(), + }); + // 图层添加到地图上 + this.map.addLayer(this.alarmLayer); + var flag=true + var animation=setInterval(() => { + flag=!flag + this.alarmLayer.setVisible(flag) + }, 300); + } + + const feature = new Feature({ + geometry: new Point(coordinate), + }); + // 设置要素的图标 + feature.setStyle( + new Style({ + // 设置图片效果 + image: new Icon({ + src: getStatisFileUrl("/map/icon_paishuibeng_h.png"), + // anchor: [0.5, 0.5], + scale: 0.4, + }), + }) + ); + // 要素添加到地图图层上 + this.alarmLayer.getSource().addFeature(feature); + + } + if(type=='equipment'){ + console.log("addPointWidthCoordinate", type, coordinate) + if (Object.keys(this.equipmentLayer).length == 0) { + // 创建图层 + this.equipmentLayer = new VectorLayer({ + source: new VectorSource(), + }); + // 图层添加到地图上 + this.map.addLayer(this.equipmentLayer); + } + + const feature = new Feature({ + geometry: new Point(coordinate), + }); + // 设置要素的图标 + feature.setStyle( + new Style({ + // 设置图片效果 + image: new Icon({ + src: getStatisFileUrl("/map/icon_paishuibeng_h_2.png"), + // anchor: [0.5, 0.5], + scale: 0.4, + }), + }) + ); + // 要素添加到地图图层上 + + this.equipmentLayer.getSource().addFeature(feature); + } + + + + + + } }, };