Skip to content

Commit

Permalink
fix markers for user messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vol4tim committed Sep 13, 2024
1 parent d4db8c7 commit 1187620
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/utils/map/marker.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const messageTypes = {
3: "water",
4: "fire",
5: "forest",
6: "alert ",
6: "alert",
7: "notif",
8: "recycle",
9: "parking",
Expand Down Expand Up @@ -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",
});
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/views/Main.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<Header />

<template v-if="point">
<MessagePopup v-if="point.data.message" @close="handlerClose" :data="point.data" />
<MessagePopup
v-if="point.measurement && point.measurement.message"
@close="handlerClose"
:data="point.measurement"
/>
<SensorPopup
v-else
:currentProvider="provider"
Expand Down

0 comments on commit 1187620

Please sign in to comment.