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-mapbox-gl-spiderifier

v1.12.0

Published

[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/thuanmb/react-mapbox-gl-spiderifier/blob/master/LICENSE) [![npm downloads](https://img.shields.io/npm/dm/react-mapbox-gl-spiderifier.svg)](https://www.npmjs.com/pack

Downloads

603

Readme

react-mapboxgl-spiderifier

GitHub license npm downloads

Rendering the spiderifier into react-mapbox-gl as React component.

Spiral/Circle positioning logic taken from and credits goes to https://github.com/jawj/OverlappingMarkerSpiderfier.

Examples:

  • https://github.com/thuanmb/react-mapbox-gl-spiderifier/blob/master/src/App.js

Demo Spiderifier.

Usage:

Simple spiderfication

Please note that the ReactMapboxGlSpiderifier should be used together with the React wrapper of mapbox-gl e.g. react-mapbox-gl. https://github.com/alex3165/react-mapbox-gl

import ReactMapboxGl from 'react-mapbox-gl';
import { ReactMapboxGlSpiderifier } from 'react-mapbox-gl-spiderifier';

const Map = ReactMapboxGl({
  accessToken: '...',
});

const mapProps = {
  style: 'mapbox://styles/mapbox/streets-v8',
};

class App extends Component {
  onStyleLoad = (map) => {
    this.map = map;
  };

  renderPopup(properties, coordinates, offset) {
    if (this.currentPopup) {
      this.currentPopup.remove();
    }

    setTimeout(() => {
      this.currentPopup = new MapboxGl.Popup({ offset })
        .setLngLat(coordinates)
        .setHTML(`Some description for node ${properties.value}`)
        .addTo(this.map);
    });
  }

  renderSpiderifierContent(key, value) {
    return (
      <div className="spiderifier-marker-content" key={key} properties={{ value }}>
        <div>{value}</div>
      </div>
    )
  }

  render() {
    return (
      <div className="App">
        <Map {...mapProps} onStyleLoad={this.onStyleLoad}>
          <ReactMapboxGlSpiderifier
            coordinates={[-0.2268, 51.5361]}
            onClick={(properties, coords, offset) => this.renderPopup(properties, coords, offset)}
           >
            {[100, 200, 300, 400, 500].((n, index) => this.renderSpiderifierContent(index, n))}
          </ReactMapboxGlSpiderifier>
        </Map>
      </div>
    );
  }
}

Documentation

Properties

  • coordinates ([number, number]) Display the Spiderifier at the given position

  • circleSpiralSwitchover (number) Show spiral instead of circle from this marker count upwards, 0 -> always spiral; Infinity -> always circle

  • circleFootSeparation (number) Related to circumference of circle

  • spiralFootSeparation (number) Related to size of spiral

  • spiralLengthStart (number) Related to size of spiral

  • spiralLengthFactor (number) Related to size of spiral

  • animate (bool) To enable animate the spiral

  • animationSpeed (number) Animation speed in milliseconds

  • transformSpiderLeft (number) The margin in left side of each spider

  • transformSpiderTop (number) The margin in top of each spider

  • showingLegs (bool) Indicate if the legs should be shown even when the spiderifier only have one spider element

Events

  • onClick (function) The click event handler

  • onMouseDown (function) The mouse down event handler

  • onMouseEnter (function) The mouse enter event handler

  • onMouseLeave (function) The mouse leave event handler

  • onMouseMove (function) The mouse move event handler

  • onMouseOut (function) The mouse out event handler

  • onMouseOver (function) The mouse over event handler

  • onMouseUp (function) The mouse up event handler

ChangeLog:

1.12.0

  • Bump dependencies version

1.11.1

  • Bump dependencies version

1.11.0

  • Bump dependencies version

1.10.0

  • Bump dependencies version

1.9.0

  • Bump dependencies version

1.6.0

  • Refactoring

1.5.0

  • Migrating the componentWill*

1.4.0

  • Upgrading packages

1.3.0

  • Upgrading packages

1.2.0

  • Upgrading packages

1.1.0

  • Upgrading packages

1.0.2

  • Fix bundling issue

1.0.1

  • Upgrading the depedencies version.

0.2.0 [BREAKING CHANGES]

  • Upgrade all packages to latest version. These packages include: react, mapbox-gl, react-mapbox-gl,...

Development

Starting the server in local

  • Adding the .env file
  • Adding the key REACT_APP_MAPBOX_GL_TOKEN into the .env file
  • Starting the server by: yarn start

Upgrading dependencies checklist

  • Pull the latest code
  • Create a new branch
  • Upgrading the dependencies
yarn upgrade-interactive --latest
  • Test if the app works after upgrading: yarn start
  • Build the package: yarn build
  • Increasing the package version in the package.json
  • Adding the release note in the README
  • Push the change into Github
  • Publish the package into npmjs: npm publish