Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
chicago ward map with props callback
Créé
il y a 5 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
2 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
53 lignes
Copier tout
3 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
51 lignes
Copier tout
Copier
Copié
Copier
Copié
function ChicagoWardMap(
) {
function ChicagoWardMap(
{ selectWard }
) {
const [wardBorders, setWardBorders] = useState(null)
const [wardBorders, setWardBorders] = useState(null)
Copier
Copié
Copier
Copié
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
Copier
Copié
Copier
Copié
const layerFeature = layer?.feature?.properties
const layerFeature = layer?.feature?.properties
? layer.feature.properties
? layer.feature.properties
: null
: null
Copier
Copié
Copier
Copié
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>
Copier
Copié
Copier
Copié
{ward && <p>Ward {ward.ward}'s shape_area = {ward.shape_area} and shape_leng = {ward.shape_leng}</p>}
</>
</>
)
)
}
}
export default ChicagoWardMap
export default ChicagoWardMap
Différences enregistrées
Texte d'origine
Ouvrir un fichier
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
Texte modifié
Ouvrir un fichier
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
Trouver la différence