Create beautiful SVG maps in react with d3-geo and topojson using a declarative api.
React-simple-maps aims to make working with svg maps in react easier. It handles tasks such as panning, zooming and simple rendering optimization, and takes advantage of parts of d3-geo and topojson-client instead of relying on the entire d3 library.
$ npm install --save react-simple-maps
...or if you use yarn:
$ yarn add react-simple-maps
React-simple-maps exposes a set of components that can be combined to create svg maps with markers and annotations. In order to render a map you have to provide a reference to a valid topojson file. You can find example topojson files in the
topojson-maps folder or on topojson world-atlas. To learn how to make your own topojson maps from shapefiles, please read "How to convert and prepare TopoJSON files for interactive mapping with d3" on medium.
import React from "react"import ReactDOM from "react-dom"importComposableMapGeographiesGeographyfrom "react-simple-maps"// url to a valid topojson fileconst geoUrl =""const App =return<div><ComposableMap><Geographies =>geographies geographies</Geographies></ComposableMap></div>document
Check out the live example
For other examples and components, check out the documentation.
MIT licensed. Copyright (c) Richard Zimerman 2017. See LICENSE.md for more details.