npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-arcgis-wmws

v0.2.4

Published

React component to display a public arcgis online webmap, webscene or feature table. Uses the ESM version of the ArcGIS Javascript API. Does not use esri-loader.

Downloads

5

Readme

react-arcgis-wmws

React ArcGIS Online WebMap / WebScene Component

Purpose

A proof of concept component for displaying and interacting with ArcGIS Online WebMaps and WebScenes, using the more modern ES modules based @arcgis/core library for the ArcGIS JS API v 4.x

Installation

npm i react-arcgis-wmws

Peer dependencies

  • react >=16.8
  • react-dom >=16.8
  • @arcgis/core >=4.18

Use

Viewer displaying a WebMap

import {Viewer} from 'react-arcgis-wmws';
<Viewer
  dimension="2d"
  itemId="f2e9b762544945f390ca4ac3671cfa72"
  style={{height:60vh}}
/>

Viewer displaying a WebScene

import {Viewer} from 'react-arcgis-wmws';
<Viewer
  dimension="3d"
  itemId="1c7a06421a314ac9b7d0fae22aa367fb"
  style={{height:60vh}}
/>

Table displaying feature data from a URL

import {TableView} from 'react-arcgis-wmws';
<TableView
  url="https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/Chicago_Covid_Daily_Cases_Deaths_and_Hospitalizations/FeatureServer/0"
  style={{height:60vh}}
/>

Table displaying feature data from an ItemId

import {TableView} from 'react-arcgis-wmws';
<TableView
  itemId="6aa49be79248400ebd28f1d0c6af3f9f"
  style={{height:60vh}}
/>

API

react-arcgis-wmws exposes two named exports:

  1. Viewer
  2. TableView

Viewer component exposes the following attributes:

  • dimension = "2d" | "3d" (required)
  • itemId = ArcGIS Online item ID string for a public WebMap or WebScene (required - ids for other item types will not work)
  • dockPopup = boolean - OPTIONAL default true - Should the popup be docked by default or not
  • showLegend = boolean - OPTIONAL default false - Should a legend be shown
  • env = "prod" (default) | "qa" | "uat" | "dev" - OPTIONAL (only useful to developers / applications with access to ArcGIS Online development or QA environments)

TableView component exposes the following attributes:

  • itemId = ArcGIS Online item ID string for a public FeatureLayer or SceneLayer
  • url = Fully qualified URL string to a public FeatureLayer or SceneLayer
  • layer = Actual FeatureLayer or SceneLayer object
  • env = "prod" (default) | "qa" | "uat" | "dev" - OPTIONAL (only used in conjunction with itemId and only useful to developers / applications with access to ArcGIS Online development or QA environments)

TableView Requires 1 and only 1 of the following attributes itemId, url, or layer. Adding more than 1 of these will cause some of them to be ignored and can also result in errors.

~~import and require are both supported~~

Only import can be used since this relies on a peer of an ES module only package

import {Viewer} from 'react-arcgis-wmws

NOTE

Both Viewer and TableView components MUST be given a real height (something that eventually resolves to a pixel value). You can achieve this by giving it an inline-style or assigning an id and using css to style the component. You can not use class(es) on either the Viewer or TableView component, they will be completely removed and overwritten by the @arcgis/core library.

Integration in your project

The Viewer component wraps the MapView and SceneView classes from the ArcGIS JS API. These classes bring the full power and weight of the ArcGIS JS API in order to display whatever what was configured to show in the map / scene. The TableView component wraps the FeatureTable widget. The initial basic styling is included in both the Viewer and TableView components directly. However, dynamically loaded styles, workers, and scripts can not be reasonably included directly in these components. This is why "@arcgis/core" is a peer dependency.

In order for the dynamic loading of the required parts of the ArcGIS JS API to work, you have 2 choices:

  1. Load the files from a CDN.
  2. Load the files from your own website.

Option #1 is the simplest and just requires that you include a CSS import statement pointing to the CSS file for the version of the ArcGIS JS API you are using and the appropriate color theme. For example, for version 4.19, you could use the following statement:

@import "https://js.arcgis.com/4.19/@arcgis/core/assets/esri/themes/light/main.css";

If you choose to host and manage the @arcgis/core assets yourself you will need to do 2 things:

  1. Copy the files from @arcgis/core/assets into an available location where you serve static files from.
  2. Set the assetsPath property of @arcgis/core/config.

You can follow along or do something similar to the instructions at @arcgis/core - Manage assets locally for your own project.

Development

  1. Clone the repo
git clone [email protected]:mpriour/react-arcgis-wmws.git
-or-
git clone https://github.com/mpriour/react-arcgis-wmws.git
  1. cd into react-arcgis-wmws
  2. run npm i
  3. make changes to the "library"
  4. test using Storybook -npm run storybook
  5. test that it builds -npm run build
  6. make a pull request to the repo