diff --git a/components/streetView/StreetView.tsx b/components/streetView/StreetView.tsx index 8f04df2..91e45a7 100644 --- a/components/streetView/StreetView.tsx +++ b/components/streetView/StreetView.tsx @@ -46,24 +46,21 @@ const floodingBtnsData: { const StreetView = () => { - const { openStreetView, setOpenStreetView } = useContext(StreetViewContext) as StreetViewType - const { marker, direction, directionDegree, setDirectionDegree } = useContext(MarkerContext) as MarkerContextType + const { openStreetView, + streetViewImgFloodHeight, + setStreetViewImgFloodHeight, + streetViewImgAngle, + setStreetViewImgAngle, + streetViewImgFullscreen, + setstreetViewImgFullscreen, + clicked, + setClicked } = useContext(StreetViewContext) as StreetViewType + const { direction, directionDegree, setDirectionDegree } = useContext(MarkerContext) as MarkerContextType const { id } = useOnClickSites() const { hovered, mouseEnterHandler, mouseLeaveHandler } = useHoverStatus(floodingBtnsData) const urlID = id < 10 ? `0${id}` : `${id}` - const [clicked, setClicked] = useState({ - "Street View": false, - "Minor Flooding": true, - "Moderate Flooding": false, - "Major Flooding": false, - }) - - const [streetViewImgFloodHeight, setStreetViewImgFloodHeight] = useState(1) - const [streetViewImgAngle, setStreetViewImgAngle] = useState(1) - const [streetViewImgFullscreen, setstreetViewImgFullscreen] = useState(false) - @@ -153,9 +150,9 @@ const StreetView = () => {
fullScreenStreetViewClickHandler("open")}>
-
Image {streetViewImgAngle}/7
+
Image {streetViewImgAngle}/8
{ - streetViewImgAngle === 1 ? + streetViewImgFloodHeight === 0 ? :
diff --git a/contexts/StreetViewContext.tsx b/contexts/StreetViewContext.tsx index dbb1169..7b61c06 100644 --- a/contexts/StreetViewContext.tsx +++ b/contexts/StreetViewContext.tsx @@ -2,7 +2,25 @@ import React, { createContext, useState, Dispatch, SetStateAction, ReactNode } f export type StreetViewType = { openStreetView: boolean | null, - setOpenStreetView: Dispatch> + setOpenStreetView: Dispatch>, + streetViewImgFloodHeight: number, + setStreetViewImgFloodHeight: Dispatch>, + streetViewImgAngle: number, + setStreetViewImgAngle: Dispatch>, + streetViewImgFullscreen: boolean, + setstreetViewImgFullscreen: Dispatch>, + clicked:{ + "Street View": boolean, + "Minor Flooding": boolean, + "Moderate Flooding": boolean, + "Major Flooding": boolean, + }, + setClicked: Dispatch> } type Props = { @@ -14,12 +32,32 @@ const StreetViewContext = createContext(null) const StreetViewProvider = ({ children }: Props) => { const [openStreetView, setOpenStreetView] = useState(false) + const [streetViewImgFloodHeight, setStreetViewImgFloodHeight] = useState(1) + const [streetViewImgAngle, setStreetViewImgAngle] = useState(1) + const [streetViewImgFullscreen, setstreetViewImgFullscreen] = useState(false) + const [clicked, setClicked] = useState({ + "Street View": false, + "Minor Flooding": true, + "Moderate Flooding": false, + "Major Flooding": false, + }) return ( - + {children} ) } -export { StreetViewContext, StreetViewProvider } \ No newline at end of file +export { StreetViewContext, StreetViewProvider } \ No newline at end of file diff --git a/hooks/useOnClickSites.tsx b/hooks/useOnClickSites.tsx index 67aae3e..9ff4a53 100644 --- a/hooks/useOnClickSites.tsx +++ b/hooks/useOnClickSites.tsx @@ -13,7 +13,7 @@ import { markerCreator } from '@/utils/markerCreator' const useOnClickSites = () => { const { map } = useContext(MapContext) as MapContextType - const { openStreetView, setOpenStreetView } = useContext(StreetViewContext) as StreetViewType + const { openStreetView, setOpenStreetView, setStreetViewImgAngle, setStreetViewImgFloodHeight, setClicked } = useContext(StreetViewContext) as StreetViewType const { setDirection, setMarker, setDirectionDegree } = useContext(MarkerContext) as MarkerContextType const [id, setId] = useState(0) @@ -37,17 +37,26 @@ const useOnClickSites = () => { } + const yaw = Math.round(e.features[0].properties.Yaw) const { direction, marker } = markerCreator(e, map) - setDirectionDegree(0) + setDirectionDegree(yaw) setDirection(prevdirection => { prevdirection?.remove() - return direction + return direction.setRotation(yaw) }) setMarker(prevmarker => { prevmarker?.remove() return marker }) + setStreetViewImgAngle(1) + setStreetViewImgFloodHeight(1) + setClicked({ + "Street View": false, + "Minor Flooding": true, + "Moderate Flooding": false, + "Major Flooding": false, + }) }); @@ -57,7 +66,7 @@ const useOnClickSites = () => { console.log(id) - return {id} + return { id } }