v3.0.0
gzip size
Github

Documentation

Getting started
Map files
Projections
Styling



Advanced

useGeographies

The useGeographies hook is used internally by react-simple-maps to generate the geographies returned by the Geographies component. By using this hook, you can create your won Geographies component with custom capabilities.

import { useGeographies, Geography } from "react-simple-maps"

const geoUrl = "/custom-topojson-file.json"

export default function CustomGeographies() {
  const { geographies, outline, borders } = useGeographies({
    geography: geoUrl,
    parseGeographies: (geos) => geos,
  })

  return (
    <g>
      {geographies.map((geo) => {
        return <Geography key={geo.rsmKey} geography={geo} />
      })}
    </g>
  )
}

jsx

The useGeographies hook takes the same options as the Geographies component (geography, parseGeographies).

If you want to fully control the entire geography rendering process, you can omit the Geography component and render out the geographies manually:

import { useGeographies } from "react-simple-maps"

const geoUrl = "/custom-topojson-file.json"

export default function CustomGeographies() {
  const { geographies, outline, borders } = useGeographies({
    geography: geoUrl,
    parseGeographies: (geos) => geos,
  })

  return (
    <g>
      {geographies.map((geo) => {
        return <path key={geo.rsmKey} d={geo.svgPath} />
      })}
    </g>
  )
}

jsx

useGeographies options

NameTypeDefault
geographyString | Object | Array
parseGeographiesFunction

Newsletter

Sign up to the React Simple Maps newsletter and be the first one to know when we publish new stuff.

Contact us

React Simple Maps was created by z creative labs. We turn ideas into digital products and specialise in dataviz and data-driven design. Are you looking for someone to create custom mapcharts and data visualisations?

Get in touch

React Simple Maps