-
Notifications
You must be signed in to change notification settings - Fork 17
updated readme, added colors to map, misc cleanup, new screenshot #1
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import React, { useEffect, useState } from "react" | ||
|
|
||
| import { MapContainer, TileLayer, GeoJSON } from "react-leaflet" | ||
|
|
||
|
|
@@ -37,6 +37,8 @@ | |
| } | ||
|
|
||
| export default function RestaurantPermitMap() { | ||
| const colors = ["#eff3ff", "#bdd7e7", "#6baed6", "#2171b5"] | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imported these from https://colorbrewer2.org/. may be worth keeping in |
||
|
|
||
| const [currentYearData, setCurrentYearData] = useState([]) | ||
| const [year, setYear] = useState(2026) | ||
|
|
||
|
|
@@ -59,17 +61,32 @@ | |
| .then((data) => setCurrentYearData(data)) | ||
| }, [currentUrl]) | ||
|
|
||
| function getColor(pcntPermits) { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this could be a function we stub out but ask them to implement |
||
| if (pcntPermits > .5) | ||
| return colors[3] | ||
| else if (pcntPermits > .2) | ||
| return colors [2] | ||
| else if (pcntPermits >= .01) | ||
| return colors [1] | ||
| else | ||
| return colors[0] | ||
| } | ||
|
|
||
| function setAreaInteraction(feature, layer) { | ||
| const thisAreaData = communityAreaDict[feature.properties.community], | ||
| numPermits = thisAreaData.num_permits, | ||
| pcntPermits = numPermits / maxNumPermits | ||
| layer.setStyle({ | ||
| fillOpacity: pcntPermits, | ||
| color: "#000000", | ||
| weight: 1, | ||
| fillOpacity: 0.7, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these default styles can be kept in |
||
| fillColor: getColor(pcntPermits) | ||
| }) | ||
| layer.on("mouseover", () => { | ||
| layer.bindPopup(` | ||
| <h3>${feature.properties.community}</h3> | ||
| <p>Restaurant permits issued during ${year}: ${thisAreaData.num_permits}</p> | ||
| <strong>${feature.properties.community}</strong><br /> | ||
| Year: ${year}<br /> | ||
| Restaurant permits: ${thisAreaData.num_permits} | ||
| `) | ||
| layer.openPopup() | ||
| }) | ||
|
|
@@ -89,11 +106,10 @@ | |
| id="restaurant-map" | ||
| center={[41.88, -87.62]} | ||
| zoom={10} | ||
| scrollWheelZoom={false} | ||
| > | ||
| <TileLayer | ||
| attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | ||
| url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
| url="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}@2x.png" | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. positron base map |
||
| /> | ||
| {currentYearData.length > 0 ? ( | ||
| <GeoJSON | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
site would not successfully come up before changing this