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

arcgis-react-redux-legend

v3.0.0

Published

Combined legend and layer list control for the Esri JS API V4. Uses React and Redux.

Downloads

12

Readme

ArcGIS JS API V4 Legend

npm

Combined legend and layer list control for the ArcGIS JS API V4.6+ that uses React and Redux

legend gif

Run locally

grab this repo (fork / download) then run npm install wait a while and then get running with npm start then go to http://localhost:3000. You can also append a webmap query paramter to load a webmap from ArcGIS Online http://localhost:3000?webmap=8e42e164d4174da09f61fe0d3f206641.

Usage

If you are using 4.3 or lower of the ArcGIS JS API then make sure you use version 1.x of this control, version 2.x is for the ArcGIS API v4.4 to v4.6., version 3.x is for v4.6 or higher

To add to your site first make sure you have the dependencies installed, we assume you are using React, Redux and Esri Loader. For the full list refer to the package.json peerDependencies.

npm install esri-loader prop-types react react-dom react-redux redux redux-thunk arcgis-react-redux-legend

you can also use this with Preact by including preact-compat, see preact-legend

Now add the reducer

import {combineReducers} from 'redux';
import {reducer as mapLegendReducer} from 'arcgis-react-redux-legend';

const reducer = combineReducers(
  {    
    mapLegendConfig: mapLegendReducer
  }
);

then where you are creating your map control you need to add the MapLegend component and initialise it

import {MapLegend,setInitialLegend} from 'arcgis-react-redux-legend';

// bootstrap the Esri API using esri-loader and create your view
// mapId should be the unique name / id to identify the map. 
// You can add multiple maps and legends so long as the mapId is unique
this.props.dispatch(setInitialLegend(view, mapId));
// in your render function, use the ref to pass to the Esri JS API when creating the map and view
<div ref={node => (this.mapView = node)}>
  <MapLegend mapId={mapId} title='My awesome legend' />
</div>

setInitialLegend will listen for your view being ready and also watch the scale changing so that the legend scale dependency updates accordingly.

For a complete example check out the source in the docs folder for map-view

Currently supports MapImageLayers, FeatureLayers, GraphicsLayers, StreamLayers, SceneLayers, PointCloudLayers, and MapNotesLayers.