Home

Awesome

DEPRECATED

This project is no longer actively maintained.


react-sceneview

A simple Esri SceneView react component that builds on the ArcGIS API for JavaScript.

Table of Contents

Installing

$ npm install --save react-sceneview

Then, just import to your React component:

import { SceneView, Scene } from 'react-sceneview';

Examples

import React from 'react';
import { render } from 'react-dom';
import { SceneView, Scene, Webscene } from 'react-sceneview';

render(
  <SceneView id="sceneview">
    <Scene>
      <Webscene  portalItem={{ id: '34859cee6739438d93262a5aa91bf834' }} />
    </Scene>
  </SceneView>,
  document.getElementById('root'),
);

Add a WebScene and/or individual layers:

<SceneView id="sceneview">
  <Scene>
    <Layer id="buildings" layerType="scene" url={SCENE_LAYER_URL} />
    <Layer id="districts" layerType="feature" url={FEATURE_LAYER_URL} />
  </Scene>
</SceneView>

Supports various features such as UI widgets, custom basemaps, selection, highlights, definitionExpression, etc...

<SceneView id="sceneview" onClick={handleSelect}>
  <UI.Zoom position="top-left" />
  <Scene>
    <CustomBasemap portalItem={{ id: 'ae53cf192181425ab999e8a19e41a6dc' }} />
    <Layer id="1" url={URL1} layerType="scene" selectable highlight={selection} />
    <Layer id="2" url={URL2} layerType="feature" definitionExpression="Scenario IN (1,2)" />
    <Layer id="3" url={URL3} layerType="feature" visible={false} />
  </Scene>
</SceneView>

Dynamically add and remove layers:

  <SceneView
    id="sceneview"
  >
    <Scene>
      {layers.map(({ layerId, ...layerSettings }) => (
        <Layer
          key={layerId}
          id={layerId}
          {...layerSettings}
        />
      ))}
    </Scene>
  </SceneView>

Supports client-side graphics: dynamically add and remove graphics from feature layer.

<SceneView id="sceneview">
  <Scene>
    <Layer
      id="points"
      layerType="feature"
      geometryType="polygon"
      fields={fields}
      objectIdField="OID"
    >
      {graphics.map(graphic => (
        <Graphic geometry={graphic.geometry} attributes={graphic.attributes} symbol={graphic.symbol} />
      )}
    </Layer>
  </Scene>
  <DrawingTool onDraw={handleDrawUpdate} />
</SceneView>

Props

SceneView

NameTypeDefaultDescription
idstringUnique id of this sceneview. This id is used to handle hot module reloading and other component refreshes.
environmentobjectEnvironment parameters of the sceneview.
goTo      objectSets the view to a given target camera or geometry.
onClickfunctionCallback fired after a click in the SceneView. Returns hit test results.
onMouseMovefunctionCallback fired after a mouse move (hover) in the SceneView. Returns hit test results.
onCameraChangefunctionA callback fired after the camera has been changed. Returns the new camera object.

Scene

NameTypeDefaultDescription
basemapstringgray-vectorSpecifies a basemap for the map. One of ['streets', 'satellite', 'hybrid', 'topo', 'gray', 'dark-gray', 'oceans', 'national-geographic', 'terrain', 'osm', 'dark-gray-vector', 'gray-vector', 'streets-vector', 'topo-vector', 'streets-night-vector', 'streets-relief-vector', 'streets-navigation-vector'].
groundstringworld-elevationSpecifies the surface properties for the map.
initialViewPropertiesobjectThis object contains properties such as viewpoint, spatialReference, viewingMode, and environment that should be applied to the SceneView when the scene loads.

Layer

NameTypeDefaultDescription
idstringUnique id used to reference the layer.
urlstringURL of scene or feature layer. If omitted, a layer source is required.
visible      booltrueIndicates if the layer is visible in the SceneView.
selectableboolfalseIndicates if features on this layer are returned in onClick and onMouseMove events, as well as from the selection tools.
highlightarray[]Feature object ids to be highlighted (usually selection).
definitionExpressionstringThe SQL where clause used to filter features on the client.
rendererobjectThe renderer assigned to the layer, supplied as an Auto-casting object.
rendererJsonobjectThe renderer assigned to the layer, supplied as a JSON object generated from a product in the ArcGIS platform.
labelingInfoobjectThe label definition for this layer, specified as an array of LabelClass.
labelsVisibleboolfalseIndicates whether to display labels for this layer.
refreshnumberChange value to refresh the layer.
outFieldsarrayAttribute fields which will be exposed (e.g., through selection callbacks).

If using client-side graphics, the following props are required:

NameTypeDefaultDescription
geometryTypestringGeometry type when using client-side graphics.
fieldsarrayAttribute fields when using client-side graphics.
objectIdFieldstringObject id field when using client-side graphics.

Graphic

NameTypeDefaultDescription
geometryobjectThe geometry that defines the graphic's location.
attributesarrayName-value pairs of fields and field values associated with the graphic.
symbolobjectThe Symbol for the graphic.

CustomBasemap

NameTypeDefaultDescription
portalItemobjectThe portal item (WebMap or WebScene) containing the custom base map.

CustomElevationLayer

NameTypeDefaultDescription
urlstringURL pointing to the Elevation layer resource on an ArcGIS Image Server.

UI.Zoom, UI.Compass, UI.NavigationToggle

NameTypeDefaultDescription
positionstringPosition of the UI widget. One of ['top-left', 'top-right', 'bottom-right', 'bottom-left']. Default is 'top-left'.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Licensing

Copyright 2019 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.