From 1187620eeaabbda63f326e3efdd7085b0b8435f7 Mon Sep 17 00:00:00 2001 From: vol4tim Date: Fri, 13 Sep 2024 18:45:49 +0400 Subject: [PATCH] fix markers for user messages --- src/utils/map/marker.js | 12 ++++++++---- src/views/Main.vue | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/utils/map/marker.js b/src/utils/map/marker.js index 01c3a7d..a768e09 100755 --- a/src/utils/map/marker.js +++ b/src/utils/map/marker.js @@ -36,7 +36,7 @@ const messageTypes = { 3: "water", 4: "fire", 5: "forest", - 6: "alert ", + 6: "alert", 7: "notif", 8: "recycle", 9: "parking", @@ -265,7 +265,7 @@ function createMarkerCircle(coord, data, colors) { function createMarkerUser(coord, data) { return L.marker(new L.LatLng(coord[0], coord[1]), { - icon: createIconMsg(data.data.type), + icon: createIconMsg(data.measurement?.type || 0), data: data, typeMarker: "msg", }); @@ -478,8 +478,12 @@ async function addMarkerUser(point) { if (!marker) { const marker = createMarker(point, colors); marker.on("click", handlerClickMarker); - if (messageTypes[point.data.type] && messagesLayers[messageTypes[point.data.type]]) { - messagesLayers[messageTypes[point.data.type]].addLayer(marker); + if ( + point.measurement && + messageTypes[point.measurement.type] && + messagesLayers[messageTypes[point.measurement.type]] + ) { + messagesLayers[messageTypes[point.measurement.type]].addLayer(marker); } } } diff --git a/src/views/Main.vue b/src/views/Main.vue index 7742fb2..b4355d8 100755 --- a/src/views/Main.vue +++ b/src/views/Main.vue @@ -3,7 +3,11 @@