From 9d637c5b585e327bf7b0937af77d6136084abb2a Mon Sep 17 00:00:00 2001 From: tuffnerdstuff Date: Mon, 29 Mar 2021 23:16:40 +0200 Subject: [PATCH 1/3] setting accuracy circle also when acc == null --- frontend/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index 3bbda17..d55b5b0 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -732,8 +732,8 @@ function processUpdate(data, init) { } // Draw an accuracy circle if GPS accuracy was provided by the // client. - if (acc !== null && shares[user].circle == null) { - shares[user].circle = L.circle([lat, lon], {radius: acc, fillColor: iconColor, fillOpacity: 0.25, color: iconColor, opacity: 0.5, interactive: false}).addTo(circleLayer); + if (shares[user].circle == null) { + shares[user].circle = L.circle([lat, lon], {radius: acc != null ? acc : 0, fillColor: iconColor, fillOpacity: 0.25, color: iconColor, opacity: 0.5, interactive: false}).addTo(circleLayer); } else if (shares[user].circle !== null) { shares[user].circle.setLatLng([lat, lon]); if (acc !== null) shares[user].circle.setRadius(acc); From 02ccb4fcd2db0d5ca2983cf1fe86cf7af5a80eca Mon Sep 17 00:00:00 2001 From: tuffnerdstuff Date: Thu, 1 Apr 2021 14:55:08 +0200 Subject: [PATCH 2/3] Checking accuracy circle !== null when setting color --- frontend/main.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/main.js b/frontend/main.js index d55b5b0..d51100c 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -732,8 +732,8 @@ function processUpdate(data, init) { } // Draw an accuracy circle if GPS accuracy was provided by the // client. - if (shares[user].circle == null) { - shares[user].circle = L.circle([lat, lon], {radius: acc != null ? acc : 0, fillColor: iconColor, fillOpacity: 0.25, color: iconColor, opacity: 0.5, interactive: false}).addTo(circleLayer); + if (acc !== null && shares[user].circle == null) { + shares[user].circle = L.circle([lat, lon], {radius: acc, fillColor: iconColor, fillOpacity: 0.25, color: iconColor, opacity: 0.5, interactive: false}).addTo(circleLayer); } else if (shares[user].circle !== null) { shares[user].circle.setLatLng([lat, lon]); if (acc !== null) shares[user].circle.setRadius(acc); @@ -856,19 +856,13 @@ function processUpdate(data, init) { } eLastSeen.textContent = unit.split("{{time}}").join(time); } - shares[user].circle.setStyle({ - fillColor: STATE_DEAD_COLOR, - color: STATE_DEAD_COLOR - }) + setAccuracyCircleColor(shares[user].circle, STATE_DEAD_COLOR); } else { eArrow.className = eArrow.className.split("dead").join(shares[user].state); if (eLabel !== null) eLabel.className = shares[user].state; var iconColor = STATE_LIVE_COLOR; if (shares[user].state == "rough") iconColor = STATE_ROUGH_COLOR; - shares[user].circle.setStyle({ - fillColor: iconColor, - color: iconColor - }); + setAccuracyCircleColor(shares[user].circle, iconColor); } } } @@ -890,6 +884,15 @@ function processUpdate(data, init) { } } +function setAccuracyCircleColor(circle, color) { + if( circle ) { + circle.setStyle({ + fillColor: color, + color: color + }); + } +} + // Calculates the distance between two points on a sphere using the Haversine // algorithm. function distance(from, to) { From 0bbea4fe649c4fb34481866d41b2999efa0f5189 Mon Sep 17 00:00:00 2001 From: Marius Lindvall Date: Fri, 24 May 2024 22:59:48 +0200 Subject: [PATCH 3/3] Code style consistency --- frontend/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/main.js b/frontend/main.js index d51100c..35df985 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -885,7 +885,7 @@ function processUpdate(data, init) { } function setAccuracyCircleColor(circle, color) { - if( circle ) { + if (circle) { circle.setStyle({ fillColor: color, color: color