feat: remove fill when district pop up is close

This commit is contained in:
vergiLgood1 2025-05-14 12:31:31 +07:00
parent 5808758855
commit f4b6d19eb2
1 changed files with 161 additions and 145 deletions

View File

@ -11,7 +11,7 @@ import TimelineLayer from "./timeline-layer"
import type { ICrimes, IIncidentLogs } from "@/app/_utils/types/crimes"
import type { IDistrictFeature } from "@/app/_utils/types/map"
import { createFillColorExpression, processCrimeDataByDistrict } from "@/app/_utils/map"
import { createFillColorExpression, getCrimeRateColor, processCrimeDataByDistrict } from "@/app/_utils/map"
import UnclusteredPointLayer from "./uncluster-layer"
import { toast } from "sonner"
@ -156,6 +156,7 @@ export default function Layers({
if (map.getLayer("clusters")) {
map.getMap().setLayoutProperty("clusters", "visibility", "visible")
}
if (map.getLayer("unclustered-point")) {
map.getMap().setLayoutProperty("unclustered-point", "visibility", "visible")
}
@ -164,6 +165,8 @@ export default function Layers({
const fillColorExpression = createFillColorExpression(null, crimeDataByDistrict)
map.getMap().setPaintProperty("district-fill", "fill-color", fillColorExpression as any)
}
}
}, [map, crimeDataByDistrict])
@ -213,6 +216,19 @@ export default function Layers({
0,
])
map.getMap().setPaintProperty("district-extrusion", "fill-extrusion-color", [
"case",
["has", "kode_kec"],
[
"match",
["get", "kode_kec"],
focusedDistrictId || "",
"transparent",
"transparent",
],
"transparent",
])
if (progress < 1) {
animationRef.current = requestAnimationFrame(animate)
} else {