The purpose of this exercise is to demonstrate simple map making using React-Leaflet.js including the ability to use the React Hooks useState()
and useEffect()
to dynamically render GeoJSON returned via API. The final result should be a working single page application which allows the user to select/change geographic boundaries dislpayed on a map.
- Clone repo to your a local directory.
- Create a new branch called "[Your Name]"
- Run
npm install
- Map Container
- Import
MapContainer
,TileLayer
andGeoJSON
components fromreact-leaflet
npm package. - Nest
TileLayer
andGeoJSON
withinMapContainer
- Import
config
from./config.json
and use to set:center
andzoom
props in<MapContainer />
url
andattribution
props in<TileLayer />
- Get
geoJSON
via API call (see below) and use to setdata
props in<GeoJSON />
- Import
- Geography Selector
- Import and use
<Dropdown selection/>
component fromsemantic-ui-react
npm package. - Get options params from imported
config
object and create option array to pass to options in<Dropdown />
- Selecting a geography should
setSelectedGeo
to be used togetGeoJSON
. getGeoJSON
should useurl
value passed fromselectedGeo
to run API call andsetGeoJSON
usingdata
proporty in response which should in turn add/change<GeoJSON />
component to the map.
- Import and use