On this page
Hooks
useGeographies
useGeographies is the data loading hook powering Geographies. You can use this hook to create your own Geographies component without render props.
Usage
import { useGeographies } from "react-simple-maps"
const Countries = () => {
const { geographies } = useGeographies({ geography: geoUrl })
return geographies.map((geo) => <path key={geo.rsmKey} d={geo.svgPath} />)
}Since useGeographies requires a projection to compoute the SVG paths for the individual geographies, it has to be called inside a MapProvider.
Parameters
An object with:
geography— a URL string, TopoJSONTopology, GeoJSONFeatureCollection, or an array of features. This prop is compared by content, so a fresh literal on each render is safe.parseGeographies— optional function to filter, sort or augment the raw features before paths are computed. Its identity is a dependency; define it outside the component or wrap it inuseCallback.
Returns
geographies— features extended withrsmKeyandsvgPath. An empty array until the data resolves.outline— outer boundary mesh, orundefined. The outline can only be computed if the input is valid TopoJSON.borders— shared internal borders mesh, orundefined. The borders can only be computed if the input is valid TopoJSON.