generated from NYCPlanning/ae-remix-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add capital projects layer to the map Enable auto highlighting Link selection between route and map style closes #8
- Loading branch information
1 parent
2b969cf
commit e41efe6
Showing
9 changed files
with
9,656 additions
and
5,486 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { useCapitalProjectsLayer } from "./useCapitalProjectsLayer.client"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { MVTLayer } from "@deck.gl/geo-layers"; | ||
import { useNavigate, useParams } from "@remix-run/react"; | ||
|
||
export interface CapitalProjectProperties { | ||
managingCodeCapitalProjectId: string; | ||
managingAgency: string; | ||
} | ||
export function useCapitalProjectsLayer() { | ||
const { managingCode, capitalProjectId } = useParams(); | ||
const navigate = useNavigate(); | ||
|
||
return new MVTLayer<CapitalProjectProperties>({ | ||
id: "capitalProjects", | ||
data: [ | ||
`${import.meta.env.VITE_ZONING_API_URL}/api/capital-projects/{z}/{x}/{y}.pbf`, | ||
], | ||
uniqueIdProperty: "managingCodeCapitalProjectId", | ||
autoHighlight: true, | ||
highlightColor: [129, 230, 217, 218], | ||
pickable: true, | ||
getFillColor: ({ properties }) => { | ||
const { managingCodeCapitalProjectId } = properties; | ||
switch (managingCodeCapitalProjectId) { | ||
case `${managingCode}${capitalProjectId}`: | ||
return [56, 178, 172, 166]; | ||
default: | ||
return [217, 107, 39, 166]; | ||
} | ||
}, | ||
getPointRadius: 5, | ||
getLineColor: [255, 255, 255, 255], | ||
getLineWidth: 1, | ||
onClick: (data) => { | ||
const managingCodeCapitalProjectId = | ||
data.object?.properties?.managingCodeCapitalProjectId; | ||
|
||
if (managingCodeCapitalProjectId === undefined) return; | ||
// Avoid adding the same capital project to the history stack | ||
if (managingCodeCapitalProjectId === `${managingCode}${capitalProjectId}`) | ||
return; | ||
const [nextManagingCode, nextCapitalProjectId] = [ | ||
managingCodeCapitalProjectId.slice(0, 3), | ||
managingCodeCapitalProjectId.slice(3), | ||
]; | ||
navigate(`capital-projects/${nextManagingCode}/${nextCapitalProjectId}`); | ||
}, | ||
updateTriggers: { | ||
getFillColor: [managingCode, capitalProjectId], | ||
getPointColor: [managingCode, capitalProjectId], | ||
}, | ||
}); | ||
} |
Empty file.
3 changes: 3 additions & 0 deletions
3
app/routes/capital-projects.$managingCode.$capitalProjectId.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function CapitalProject() { | ||
return <></>; | ||
} |
Oops, something went wrong.