Diff
checker
文本
文本
圖像
文檔
Excel
文件夾
Legal
Enterprise
桌面版
定價
登入
下載 Diffchecker 桌面版
比較文本
尋找兩個文字檔案之間的差異
工具
歷史
即時編輯器
摺疊未變更行
關閉換行
檢視
拆分
統一
比對精度
智能
單詞
字符
語法突出顯示
選擇語法
忽略
文字轉換
前往第一個差異
編輯輸入
Diffchecker Desktop
執行Diffchecker最安全的方式。取得Diffchecker桌面應用程式:您的差異永遠不會離開您的電腦!
取得桌面版
chicago ward map with props callback
建立於
5 年前
差異永不過期
清除
匯出
分享
解釋
2 刪除
行
總計
刪除
字符
總計
刪除
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
53 行
全部複製
3 新增
行
總計
新增
字符
總計
新增
要繼續使用此功能,請升級到
Diff
checker
Pro
查看價格
51 行
全部複製
複製
已複製
複製
已複製
function ChicagoWardMap(
) {
function ChicagoWardMap(
{ selectWard }
) {
const [wardBorders, setWardBorders] = useState(null)
const [wardBorders, setWardBorders] = useState(null)
複製
已複製
複製
已複製
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
複製
已複製
複製
已複製
const layerFeature = layer?.feature?.properties
const layerFeature = layer?.feature?.properties
? layer.feature.properties
? layer.feature.properties
: null
: null
複製
已複製
複製
已複製
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>
複製
已複製
複製
已複製
{ward && <p>Ward {ward.ward}'s shape_area = {ward.shape_area} and shape_leng = {ward.shape_leng}</p>}
</>
</>
)
)
}
}
export default ChicagoWardMap
export default ChicagoWardMap
已保存差異
原始文本
開啟檔案
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
更改後文本
開啟檔案
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
尋找差異