Skip to content

Commit e9ba8ff

Browse files
committed
Tweak map pin size
1 parent 67ceb71 commit e9ba8ff

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

src/components/WorldMap.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,17 +103,17 @@ const WorldMap = ({ orchestrators, selectedKPI }) => {
103103
};
104104

105105
// Helper to determine pin color based on KPI score
106-
const getPinColor = (score, isSelected) => {
107-
if (isSelected) return 'yellow'; // Highlight selected item with yellow
106+
const getPinColor = (score) => {
108107
if (score === null || score === undefined || score <= 0) return "gray"; // Default for missing data
109108
const normalized = Math.min(Math.max(score, 0), 1); // Normalize to [0, 1]
110109
return interpolateColor(normalized);
111110
};
112111

113112
// Custom cluster icon
114-
const createClusterCustomIcon = (cluster, isSelected) => {
113+
const createClusterCustomIcon = (cluster) => {
115114
const childCount = cluster.getChildCount();
116115
const childMarkers = cluster.getAllChildMarkers();
116+
117117
const avgScore = (
118118
childMarkers
119119
.map((marker) => {
@@ -125,8 +125,8 @@ const WorldMap = ({ orchestrators, selectedKPI }) => {
125125
.reduce((sum, score) => sum + score, 0) / childCount
126126
).toFixed(2);
127127

128-
const size = Math.min(20 + childCount * 2, 80);
129-
const color = getPinColor(avgScore, isSelected);
128+
let size = Math.min(20 + childCount * 2, 80);
129+
const color = getPinColor(avgScore);
130130

131131
return L.divIcon({
132132
className: "dummy",
@@ -182,7 +182,7 @@ const WorldMap = ({ orchestrators, selectedKPI }) => {
182182
showCoverageOnHover={false}
183183
spiderfyOnMaxZoom={false}
184184
zoomToBoundsOnClick={false}
185-
iconCreateFunction={(cluster) => createClusterCustomIcon(cluster, cluster?.layer?.getAllChildMarkers() === selectedData || false)}
185+
iconCreateFunction={(cluster) => createClusterCustomIcon(cluster)}
186186
eventHandlers={{
187187
clusterclick: (e) => {
188188
const cluster = e.layer;
@@ -203,12 +203,13 @@ const WorldMap = ({ orchestrators, selectedKPI }) => {
203203
}}
204204
icon={L.divIcon({
205205
className: "dummy",
206-
html: `<div class="custom-pin" style="background-color: ${getPinColor(
207-
instance[selectedKPI],
208-
selectedData?.instanceScore === instance[selectedKPI] &&
209-
selectedData?.orchObj === instance?.orchObj &&
210-
selectedData?.instanceObj === instance?.instanceObj
211-
)}; width: 24px; height: 24px; border-radius: 50%;"></div>`,
206+
html: `<div class="custom-pin" style="background-color: ${selectedData?.instanceObj?.id === instance.id ? "var(--magenta)" :
207+
getPinColor(instance[selectedKPI])
208+
}; width: ${selectedData?.instanceObj?.id === instance.id ? "36px" :
209+
"24px"
210+
}; height: ${selectedData?.instanceObj?.id === instance.id ? "36px" :
211+
"24px"
212+
}; border-radius: 50%;"></div>`,
212213
})}
213214
eventHandlers={{
214215
click: () => {

0 commit comments

Comments
 (0)