Diff
checker
Text
Text
Images
Documents
Excel
Folders
Legal
Enterprise
Desktop
Pricing
Sign in
Download Diffchecker Desktop
Compare text
Find the difference between two text files
Tools
History
Real-time editor
Hide unchanged lines
Disable line wrap
Layout
Split
Unified
Diff precision
Smart
Word
Char
Syntax highlighting
Choose syntax
Ignore
Transform text
Go to first change
Edit input
Diffchecker Desktop
The most secure way to run Diffchecker. Get the Diffchecker Desktop app: your diffs never leave your computer!
Get Desktop
chicago ward map with props callback
Created
5 years ago
Diff never expires
Clear
Export
Share
Explain
2 removals
Lines
Total
Removed
Characters
Total
Removed
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
53 lines
Copy
3 additions
Lines
Total
Added
Characters
Total
Added
To continue using this feature, upgrade to
Diff
checker
Pro
View Pricing
51 lines
Copy
Copy
Copied
Copy
Copied
function ChicagoWardMap(
) {
function ChicagoWardMap(
{ selectWard }
) {
const [wardBorders, setWardBorders] = useState(null)
const [wardBorders, setWardBorders] = useState(null)
Copy
Copied
Copy
Copied
const [ward, setWard] = useState(null)
useEffect(() => {
useEffect(() => {
// get the geojson
// get the geojson
fetch('https://raw.githubusercontent.com/datamade/chicago-judicial-elections/master/wards/wards_2012.geojson')
fetch('https://raw.githubusercontent.com/datamade/chicago-judicial-elections/master/wards/wards_2012.geojson')
.then((res) => res.json()) // parse the response into json
.then((res) => res.json()) // parse the response into json
.then((geojson) => {
.then((geojson) => {
setWardBorders(geojson) // with the geojson, set the state for wardBorders
setWardBorders(geojson) // with the geojson, set the state for wardBorders
})
})
}, [setWardBorders])
}, [setWardBorders])
const fill = {
const fill = {
fillColor: '#daf0ce',
fillColor: '#daf0ce',
weight: 0.5,
weight: 0.5,
opacity: 0.4,
opacity: 0.4,
color: '#666',
color: '#666',
fillOpacity: 0.5
fillOpacity: 0.5
}
}
function onWardClick(e) {
function onWardClick(e) {
const layer = e.target
const layer = e.target
Copy
Copied
Copy
Copied
const layerFeature = layer?.feature?.properties
const layerFeature = layer?.feature?.properties
? layer.feature.properties
? layer.feature.properties
: null
: null
Copy
Copied
Copy
Copied
se
tWard(layerFeature)
se
lec
tWard(layerFeature)
}
}
function eventHandlersOnEachFeature(feature, layer) {
function eventHandlersOnEachFeature(feature, layer) {
layer.on({
layer.on({
click: onWardClick
click: onWardClick
})
})
}
}
return (
return (
<>
<>
<BaseMap center={[41.8781, -87.6298]} zoom={10}>
<BaseMap center={[41.8781, -87.6298]} zoom={10}>
{/* this will only show when wardBorders has a value */}
{/* this will only show when wardBorders has a value */}
{wardBorders && <GeoJSON
{wardBorders && <GeoJSON
key='ward-layer'
key='ward-layer'
data={wardBorders}
data={wardBorders}
style={fill}
style={fill}
onEachFeature={eventHandlersOnEachFeature} />}
onEachFeature={eventHandlersOnEachFeature} />}
</BaseMap>
</BaseMap>
Copy
Copied
Copy
Copied
{ward && <p>Ward {ward.ward}'s shape_area = {ward.shape_area} and shape_leng = {ward.shape_leng}</p>}
</>
</>
)
)
}
}
export default ChicagoWardMap
export default ChicagoWardMap
Saved diffs
Original text
Open file
function ChicagoWardMap() { const [wardBorders, setWardBorders] = useState(null) const [ward, setWard] = useState(null) useEffect(() => { // get the geojson fetch('https://raw.githubusercontent.com/datamade/chicago-judicial-elections/master/wards/wards_2012.geojson') .then((res) => res.json()) // parse the response into json .then((geojson) => { setWardBorders(geojson) // with the geojson, set the state for wardBorders }) }, [setWardBorders]) const fill = { fillColor: '#daf0ce', weight: 0.5, opacity: 0.4, color: '#666', fillOpacity: 0.5 } function onWardClick(e) { const layer = e.target const layerFeature = layer?.feature?.properties ? layer.feature.properties : null setWard(layerFeature) } function eventHandlersOnEachFeature(feature, layer) { layer.on({ click: onWardClick }) } return ( <> <BaseMap center={[41.8781, -87.6298]} zoom={10}> {/* this will only show when wardBorders has a value */} {wardBorders && <GeoJSON key='ward-layer' data={wardBorders} style={fill} onEachFeature={eventHandlersOnEachFeature} />} </BaseMap> {ward && <p>Ward {ward.ward}'s shape_area = {ward.shape_area} and shape_leng = {ward.shape_leng}</p>} </> ) } export default ChicagoWardMap
Changed text
Open file
function ChicagoWardMap({ selectWard }) { const [wardBorders, setWardBorders] = useState(null) useEffect(() => { // get the geojson fetch('https://raw.githubusercontent.com/datamade/chicago-judicial-elections/master/wards/wards_2012.geojson') .then((res) => res.json()) // parse the response into json .then((geojson) => { setWardBorders(geojson) // with the geojson, set the state for wardBorders }) }, [setWardBorders]) const fill = { fillColor: '#daf0ce', weight: 0.5, opacity: 0.4, color: '#666', fillOpacity: 0.5 } function onWardClick(e) { const layer = e.target const layerFeature = layer?.feature?.properties ? layer.feature.properties : null selectWard(layerFeature) } function eventHandlersOnEachFeature(feature, layer) { layer.on({ click: onWardClick }) } return ( <> <BaseMap center={[41.8781, -87.6298]} zoom={10}> {/* this will only show when wardBorders has a value */} {wardBorders && <GeoJSON key='ward-layer' data={wardBorders} style={fill} onEachFeature={eventHandlersOnEachFeature} />} </BaseMap> </> ) } export default ChicagoWardMap
Find difference