0.2.1 • Published 6 years ago

react-arcgis-js v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

react-arcgis-js

A set of React components for the 4.0 version of the ArcGIS API for JavaScript

Build Status

alt text

Installation

Add the package from npm:

$ npm install --save react-arcgis-js
# or
$ yarn add react-arcgis-js

Load the JS API styles:

<link href="https://js.arcgis.com/4.6/esri/css/main.css" rel="stylesheet">

Basic Usage

Render a Map:

import React from 'react';
import ReactDOM from 'react-dom';
import { Map } from 'react-arcgis-js';

ReactDOM.render(
  <Map />,
  document.getElementById('root')
);

Render a Map and FeatureLayer

import React from 'react';
import ReactDOM from 'react-dom';
import { Map, Feature } from 'react-arcgis-js';

ReactDOM.render(
  <Map>
    <Feature itemId="8444e275037549c1acab02d2626daaee"/>
  </Map>,
  document.getElementById('root')
);

Examples available at https://brygrill.github.io/react-arcgis-js

Components

Map

Render a Map or WebMap. Pass an itemId prop to render WebMap via Portal Item ID or pass a baseMap prop to render a Map.

Props:

PropertyTypeRequiredDefaultDescription
itemIdstringfalseNoneId of webmap to load
baseMapstringfalsestreets-navigation-vectorBasemap to load
heightstringfalse500pxheight of map container in px or %
widthstringfalse100%width of map container in px or %
centerarrayfalse-122.41, 37.77coordinates to center the map on
zoomnumberfalse10starting zoom level of the map
webGLbooleanfalsefalseload dojo config to enable WebGL Feature Layers
onLoadingContentanyfalseLoading...string or component to render while loading map
onErrorContentanyfalseError loading map...string or component to render on error
onErrorfunctionfalseNoneWill return on error to handle as you wish
onMapClickfunctionfalseNoneWill return mapPoint and graphics object on map click

Map Children:
The following props are passed to child components of <Map/>:

PropertyTypeDescription
mapobjectMap or WebMap object
viewobjectMapView object
loadingbooleanloading status
errorbooleanerror status

Feature

Render a FeatureLayer as a child of <Map/> component. Pass a url prop to render via service URL or itemId to render via Portal Item ID.

Props:

PropertyTypeRequiredDefaultDescription
urlstringfalseNonerender FeatureLayer via service URL
itemIdstringfalseNonerender FeatureLayer via Portal Item ID

Acknowledgments

Wouldn't be possible without these projects: