react-webmap v0.2.0
React WebMap Framework
WORK IN PROGRESS..
This framework combine two libraries as Leaflet.js and React. It think how web mapping library like Leaflet.js coexist with concepts of React.
It does not use Shadow DOM for rendering a map and configuring layers because L.map do all these for mapping. But it is low reusability to define states of a map and configure layers in Leaflet.js.. Therefore, it uses ArcGIS Web Map to put full information for mapping data out. It is able to initialize a structure just with web map id.

See the live demo.
Usage
Install react-webmap via npm.
npm i react-webmapImport Mediator component from the library.
import { Mediator } from 'react-webmap';Add the component to your render function:
const mapid = '55e02e777274468c90745fde6641faf4'; // You can get mapid from ArcGIS!
ReactDOM.render(<Mediator mapid={mapid} />, container);You can get a mapid from ArcGIS.com. See Make your first map.
Development Instructions
You can create new Reactor or improve the framework for Mediator or Reactors as the below.
- Fork and clone react-webmap
cdinto thereact-webmapfolder- Install the dependencies with
npm install - Run
npm run buildfrom the command line. This will compile JSX in a brand newdistdirectory. - Run
npm run startto compile an example codes to minified source in adocsdirectory and launch a tiny webserver. Run( IN PREPARATION)npm testto make sure you haven't introduced a new 'feature' accidentally.- Make your changes in its own topic branch and create a pull request!
Recipe for Reactor
- Make a directory (e.g.
HomeButton) for new Reactor intosrc/example/reactors. - Make and open a js file (e.g.
HomeButton.js) in your text editor. - Create new class (named the same of the file) extend
React.Componentwith ES2015. - Define
props(e.g.center,zoom) for getting data from a map viaMediator. - Make a function for render data or action to a map.
- Make a event (e.g.
<Button onClick={this._onGetHome}>runsthis.props.onGetHome) on Reactor to move a map or highlight data (OPTION) - Add new Reactor into
Mediator.jswithimport. - Add new property into
Mediator.propsto initialize your Reactor (OPTION). - Add JSX markup of new Reactor (e.g.
<HomeButton />) intorender()ofMediator. - Set
propsinto JSX (e.g.<HomeButton center={this.state.initialCenter} zoom={this.state.initialZoom} />) withthis.state. - Add a funtion for using Leaflet methods and bind it with
this(e.g.this.fitBounds = this.fitBounds.bind(this);) in theloadevent listner forL.esri.webMap(OPTION).
HomeButton.js
import React from 'react';
import { Button, Glyphicon } from 'react-bootstrap';
class HomeButton extends React.Component {
constructor (props) {
super(props);
this._onGetHome = this._onGetHome.bind(this);
}
_onGetHome () {
this.props.onGetHome(this.props.center, this.props.zoom);
}
render () {
return (
<div>
<Button onClick={this._onGetHome}>
<Glyphicon glyph="home" />
</Button>
</div>
);
}
}
HomeButton.propTypes = {
center: React.PropTypes.array,
zoom: React.PropTypes.number,
onGetHome: React.PropTypes.func
};
HomeButton.defaultProps = {
center: [35, 139],
zoom : 5,
onGetHome: function () {}
};
HomeButton.displayName = 'HomeButton';
export default HomeButton;