Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: highlight borders on hover fix #523 #527

Open
wants to merge 3 commits into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 29 additions & 7 deletions components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function Map({
const [municipalityFeatureCollection, setMunicipalityFeatureCollection] = useState<any>({})
// "tapped" municipality tooltips are only to be used on touch devices.
const [lastTapInfo, setLastTapInfo] = useState<MunicipalityTapInfo | null>(null)
const wrapperRef = useRef<HTMLDivElement|null>(null)
const wrapperRef = useRef<HTMLDivElement | null>(null)

const router = useRouter()

Expand Down Expand Up @@ -224,25 +224,47 @@ function Map({
},
)

const municipalityLayer = new PolygonLayer({


const [hoveredItem, setHoveredItem] = useState<MunicipalityData | null>(null);
const municipalityLayer = new PolygonLayer<MunicipalityData>({
id: 'polygon-layer',
data: municipalityLines,
stroked: true,
filled: true,
extruded: false,
wireframe: false,
lineWidthUtils: 'pixels',
lineWidthMinPixels: 0.5,
getLineWidth: 80,
lineWidthUnits: "common",
lineJointRounded: true,
getElevation: 0,
polygonOffset: 1,
lineWidthMaxPixels: 4,
lineWidthMinPixels: 0.05,
getPolygon: (k: any) => k.geometry,
getLineColor: () => [0, 0, 0, 80],
getLineColor: (item) => {
if (hoveredItem && item?.name === hoveredItem?.name) {
return [0, 0, 0, 255] as RGBAColor
} else {
return [0, 0, 0, 80] as RGBAColor
}
},
getLineWidth: (item) => {
if (item?.name === hoveredItem?.name) {
return 0.1
} else {
return 0.01
}
},
getFillColor: (d) => getColor((d as MunicipalityData).dataPoint, boundaries),
pickable: true,
onHover: (info, _input) => {
if (info.object?.name !== hoveredItem?.name) {
setHoveredItem(info.object)
}
}
})



return (
<DeckGLWrapper ref={wrapperRef}>
<NextNProgress
Expand Down