All Projects → gabidavila → React Usa Map

gabidavila / React Usa Map

Licence: mit
React component with all USA States with customizable options. No D3 needed.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Usa Map

Geojson2svg
Converts geojson to svg string given svg viewport size and maps extent.
Stars: ✭ 117 (+85.71%)
Mutual labels:  svg, map
Jquery Mapael
jQuery plugin based on raphael.js that allows you to display dynamic vector maps
Stars: ✭ 981 (+1457.14%)
Mutual labels:  svg, map
React Svg Map
A set of React.js components to display an interactive SVG map
Stars: ✭ 150 (+138.1%)
Mutual labels:  svg, map
Svg World Map
🗺 A JavaScript library to easily integrate one or more SVG world maps with all nations (countries) and second-level political subdivisions (countries, provinces, states).
Stars: ✭ 38 (-39.68%)
Mutual labels:  svg, map
Svgmap
svg地图组件,完整版包含城市及区县数据及更多扩展功能。。。
Stars: ✭ 298 (+373.02%)
Mutual labels:  svg, map
Vue Svg Map
A set of Vue.js components to display an interactive SVG map
Stars: ✭ 48 (-23.81%)
Mutual labels:  svg, map
Calendar Graph
Calendar graph like github using jsx support SVG, Canvas and SSR
Stars: ✭ 58 (-7.94%)
Mutual labels:  svg
Fontello Svg
Generate SVG icons from a Fontello icon set.
Stars: ✭ 59 (-6.35%)
Mutual labels:  svg
Cwl Svg
A library for generating an interactive SVG visualization of CWL workflows
Stars: ✭ 57 (-9.52%)
Mutual labels:  svg
Bikedeboa
A (Progressive) Web App to find, map and review bike parkings in the cities of Brazil.
Stars: ✭ 54 (-14.29%)
Mutual labels:  map
Svg2jsx
🍃 Transform SVG to valid JSX.
Stars: ✭ 1,116 (+1671.43%)
Mutual labels:  svg
Govicons
🇺🇸 US Government themed icons and CSS toolkit
Stars: ✭ 60 (-4.76%)
Mutual labels:  svg
React No Content
A SVG react component to display when there's no content.
Stars: ✭ 59 (-6.35%)
Mutual labels:  svg
Openhtmltopdf
An HTML to PDF library for the JVM. Based on Flying Saucer and Apache PDF-BOX 2. With SVG image support. Now also with accessible PDF support (WCAG, Section 508, PDF/UA)!
Stars: ✭ 1,096 (+1639.68%)
Mutual labels:  svg
Svgpocketguide
All original content of A Pocket Guide to Writing SVG by Joni Trythall
Stars: ✭ 1,106 (+1655.56%)
Mutual labels:  svg
Vmware Stencils
Official VMware Stencils
Stars: ✭ 57 (-9.52%)
Mutual labels:  svg
Flutter svg
SVG parsing, rendering, and widget library for Flutter
Stars: ✭ 1,113 (+1666.67%)
Mutual labels:  svg
Cdcontainers
Library of data containers and data structures for C programming language.
Stars: ✭ 57 (-9.52%)
Mutual labels:  map
Boxicons
High Quality web friendly icons
Stars: ✭ 1,104 (+1652.38%)
Mutual labels:  svg
Vscode Svgviewer
SVG Viewer for Visual Studio Code
Stars: ✭ 60 (-4.76%)
Mutual labels:  svg

react-usa-map | A simple SVG USA map rendering on React

Build Status codebeat badge

This is an alternate version for you that just want a simple customizable map on HTML. This maps shows states delimitations including DC, Alaska, and Hawaii. D3 is not needed.

It uses the Albers projection.

Live Example

Live: http://react-usa-map-demo.herokuapp.com

Code: http://github.com/gabidavila/react-usa-map-demo

Installation

It requires react 16.13.1 or higher. Run:

yarn add react-usa-map

or

npm install react-usa-map --save

Usage

The below example shows the mandatory onClick event.

import React, { Component } from 'react';
import USAMap from "react-usa-map";

class App extends Component {
  /* mandatory */
  mapHandler = (event) => {
    alert(event.target.dataset.name);
  };

  render() {
    return (
      <div className="App">
        <USAMap onClick={this.mapHandler} />
      </div>
    );
  }
}

export default App;

Example with optional props, App.js:

import React, { Component } from 'react';
import './App.css'; /* optional for styling like the :hover pseudo-class */
import USAMap from "react-usa-map";

class App extends Component {
  /* mandatory */
  mapHandler = (event) => {
    alert(event.target.dataset.name);
  };

  /* optional customization of filling per state and calling custom callbacks per state */
  statesCustomConfig = () => {
    return {
      "NJ": {
        fill: "navy",
        clickHandler: (event) => console.log('Custom handler for NJ', event.target.dataset)
      },
      "NY": {
        fill: "#CC0000"
      }
    };
  };

  render() {
    return (
      <div className="App">
        <USAMap customize={this.statesCustomConfig()} onClick={this.mapHandler} />
      </div>
    );
  }
}

export default App;

App.css:

path {
  pointer-events: all;
}
path:hover {
  opacity: 0.50;
  cursor: pointer;
}

All optional props:

prop description
title Content for the Title attribute on the svg
width The width for rendering, numeric, no px suffix
height The height for rendering, numeric, no px suffix
defaultFill The default color for filling
customize Optional customization of filling per state

Additionally each path tag has an abbreviation of the current state followed by a state class:

<path fill="#{custom color or #D3D3D3}" data-name="CA" class="CA state" d="...{polygon dimensions here}..."></path>

License

MIT.

Sources

The map is sourced from Wikimedia and is under Creative Commons Attribution-Share Alike 3.0 Unported license. This package is inspired on the react-us-state-map package, in fact the initial SVG class system is based on it.

Contributing

Fork and PR. Not much fuss, I will be try to be as responsive as possible.

Maintainer

Package maintaned by Gabriela D'Ávila Ferrara, website.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].