Skip to content

Commit

Permalink
Added debug layer group toggle, minor style change and removed unused…
Browse files Browse the repository at this point in the history
… file.
  • Loading branch information
a-limyr committed Jan 23, 2025
1 parent 8e6d6f1 commit 131f301
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 57 deletions.
38 changes: 0 additions & 38 deletions client/src/components/MapView/DebugLayerButton.tsx

This file was deleted.

67 changes: 49 additions & 18 deletions client/src/components/MapView/LayerControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,34 +134,65 @@ const LayerControl: React.FC<LayerControlProps> = ({ mapRef, setInteractiveLayer

{/* DEBUG (VECTOR) LAYERS */}
<h4 style={{ marginTop: '1rem' }}>Debug Layers</h4>
{Object.entries(layerGroups).map(([groupName, layers]) => (
<div key={groupName} style={{ marginBottom: '10px' }}>
<h6 style={{ margin: '0 0 5px' }}>{groupName}</h6>
{layers.map((layer) => {
// Grab the map property for whether it’s visible or not:
const isVisible = mapRef?.getMap().getLayoutProperty(layer.id, 'visibility') !== 'none';

return (
{Object.entries(layerGroups).map(([groupName, layers]) => {
// Determine if *all* layers in this group are currently visible.
const allVisible = layers.every(
(layer) => mapRef?.getMap().getLayoutProperty(layer.id, 'visibility') !== 'none',
);

// Define a helper to toggle all layers in the group at once.
const toggleGroupVisibility = (checked: boolean) => {
layers.forEach((layer) => {
toggleLayerVisibility(layer.id, checked);
});
};

return (
<div key={groupName} style={{ marginBottom: '10px' }}>
<h6 style={{ margin: '0 0 5px' }}>
<label
key={layer.id}
style={{
display: 'block',
display: 'flex',
alignItems: 'center',
cursor: 'pointer',
marginBottom: '5px',
}}
>
<input
type="checkbox"
checked={isVisible}
onChange={(e) => toggleLayerVisibility(layer.id, e.target.checked)}
checked={allVisible}
onChange={(e) => toggleGroupVisibility(e.target.checked)}
style={{ marginRight: '5px' }}
/>
{layer.name}
{groupName}
</label>
);
})}
</div>
))}
</h6>

{layers.map((layer) => {
// Figure out if the layer is visible or not:
const isVisible = mapRef?.getMap().getLayoutProperty(layer.id, 'visibility') !== 'none';

return (
<label
key={layer.id}
style={{
display: 'block',
cursor: 'pointer',
marginBottom: '5px',
}}
>
<input
type="checkbox"
checked={isVisible}
onChange={(e) => toggleLayerVisibility(layer.id, e.target.checked)}
style={{ marginLeft: '20px', marginRight: '5px' }}
/>
{layer.name}
</label>
);
})}
</div>
);
})}
</div>
);
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@
.sidebar-button.right {
position: absolute;
right: 0; /* Default position when sidebar is closed */
background: #ccc;
background: #fff;
color: white;
border: none;
border-radius: 4px;
Expand Down

0 comments on commit 131f301

Please sign in to comment.