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-map-gl-3

v3.0.0-alpha.13

Published

A React wrapper for MapboxGL-js and overlay API.

Downloads

4

Readme

screen

Installation

npm install --save react-map-gl

Using with Browserify, Webpack etc

  • browserify - react-map-gl is extensively tested with browserify and works without configuration.

  • webpack 2 - look at the exhibit-webpack folder, demonstrating a working demo using webpack.

In general, for non-browserify based environments, make sure you have read the instructions on the mapbox-gl-js README.

Example

import MapGL from 'react-map-gl';

<MapGL
  width={400}
  height={400}
  latitude={37.7577}
  longitude={-122.4376}
  zoom={8}
  onChangeViewport={viewport => {
    const {latitude, longitude, zoom} = viewport;
    // Optionally call `setState` and use the state to update the map.
  }}
/>

Components

react-map-gl provides React-friendly components like Marker, Popup etc.

Visualizing Geospatial Data

The main point of using a map is usuallt to visualize geospatial data on top of it. react-map-gl provides several solutions

deck.gl Layers

deck.gl is a companion module to react-map-gl that provide a number of classic data visualization overlays (scatterplots, choropleths etc) implemented in WebGL. These overlays are suitable for very large and/or dynamic data sets, and for use in perspective mode applications.

Overlays

react-map-gl provides a basic overlay API. You can use the built-in visualization overlays, or create your own.

Perspective Mode

react-map-gl fully supports mapbox-gl perspective mode (pitch and bearing).

In addition, for a set of high-performance geospatial data visualiation overlays that are 100% compatible with mapbox-gl perspective mode, look at deck.gl.

Transitions

TBD

ImmutableJS

The mapStyle property of the MapGL as well as several of the built in overlay properties must be provided as ImmutableJS objects. This allows the library to be fast since computing changes to props only involves checking if the immutable objects are the same instance.

Development

Install project dependencies and check that the tests run

npm install
npm test

Note on yarn: yarn does not appear to be compatible with mapbox-gl v0.31, in terms of installing correct versions of dependencies needed to run test scripts in the folder. While this is likely to change, for now it is recommended it is recommended to use npm install in the root folder of react-map-gl. This restriction only applies when installing in the root folder; yarn is still supported and recommended when installing the examples in the examples folder.

Then start the main example in examples/main by running the shortcut

npm start

This should open a new tab in your browser with the examples. To make the maps load, either:

  • add ?access_token=TOKEN to the URL where TOKEN is a valid Mapbox access token, or
  • set the MapboxAccessToken environment variable before running npm start

Testing

  • Unit Tests - it is expected that any feature is accompanied by standard unit tests in test folder.
  • Run Unit Tests in Node - Note that This component uses WebGL, but it still runs under Node.js (using headless-gl and jsdom). This is how the standard npm test script runs.
  • Run Unit Tests in Browser - It is also important to run unit tests in the browser, via npm run test-browser.
  • Manual Testing - In addition, please test drive new and existing features by running npm start and manually testing the demos.

Contributing

Contributions are welcome. It can be helpful to check with maintainers before opening your PR, just open an issue and describe your proposal. Also, be aware that you will need to complete a short open source contribution form before your pull request can be accepted.