Skip to content

Commit

Permalink
solved the retoggling map layer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
CloudLun committed Mar 23, 2024
1 parent 4c01e2f commit 3cddd58
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion components/map/mapLayer/MapLayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const MapLayer = () => {
return (
<>
<MapLayerBtns clicked={clicked} buttonClickHandler={buttonClickHandler} />
{clicked === 'Layers' ? <MapLayerCards buttonClickHandler={buttonClickHandler} setLayerName={setLayerName} /> : clicked === 'Legend' ? <Legend buttonClickHandler={buttonClickHandler} layerName={layerName} /> : null}
{clicked === 'Layers' ? <MapLayerCards buttonClickHandler={buttonClickHandler} setLayerName={setLayerName} layerName={layerName} /> : clicked === 'Legend' ? <Legend buttonClickHandler={buttonClickHandler} layerName={layerName} /> : null}
</>
)
}
Expand Down
5 changes: 3 additions & 2 deletions components/map/mapLayer/MapLayerCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useMediaQuery } from 'react-responsive'

type Props = {
buttonClickHandler: (btn: btnsType) => void
layerName: floodingTypes
setLayerName: Dispatch<SetStateAction<floodingTypes>>
}

Expand Down Expand Up @@ -50,11 +51,11 @@ const layers: {
]


const MapLayerCards = ({ buttonClickHandler, setLayerName }: Props) => {
const MapLayerCards = ({ buttonClickHandler, setLayerName, layerName }: Props) => {

const { map } = useContext(MapContext) as MapContextType

const [clicked, setClicked] = useState(layers.map((l, i) => i === 0 ? true : false))
const [clicked, setClicked] = useState(layers.map((l, i) => l.title === layerName ? true : false))

const { hovered, mouseEnterHandler, mouseLeaveHandler } = useHoverStatus(layers)

Expand Down

0 comments on commit 3cddd58

Please sign in to comment.