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-webmap

v0.2.0

Published

Web Mapping Framework for React.

Downloads

18

Readme

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-webmap

Import 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.

  1. Fork and clone react-webmap
  2. cd into the react-webmap folder
  3. Install the dependencies with npm install
  4. Run npm run build from the command line. This will compile JSX in a brand new dist directory.
  5. Run npm run start to compile an example codes to minified source in a docs directory and launch a tiny webserver.
  6. ~~Run npm test to make sure you haven't introduced a new 'feature' accidentally.~~ ( IN PREPARATION)
  7. Make your changes in its own topic branch and create a pull request!

Recipe for Reactor

  1. Make a directory (e.g. HomeButton) for new Reactor into src/example/reactors.
  2. Make and open a js file (e.g. HomeButton.js) in your text editor.
  3. Create new class (named the same of the file) extend React.Component with ES2015.
  4. Define props (e.g. center, zoom) for getting data from a map via Mediator.
  5. Make a function for render data or action to a map.
  6. Make a event (e.g. <Button onClick={this._onGetHome}> runs this.props.onGetHome) on Reactor to move a map or highlight data (OPTION)
  7. Add new Reactor into Mediator.js with import.
  8. Add new property into Mediator.props to initialize your Reactor (OPTION).
  9. Add JSX markup of new Reactor (e.g. <HomeButton />) into render() of Mediator.
  10. Set props into JSX (e.g. <HomeButton center={this.state.initialCenter} zoom={this.state.initialZoom} />) with this.state.
  11. Add a funtion for using Leaflet methods and bind it with this (e.g. this.fitBounds = this.fitBounds.bind(this);) in the load event listner for L.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;