react-map-gl

WebJar for react-map-gl

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

react-map-gl
Last Version

Last Version

2.0.3
Release Date

Release Date

Type

Type

jar
Description

Description

react-map-gl
WebJar for react-map-gl
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/uber/react-map-gl

Download react-map-gl

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/react-map-gl/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>react-map-gl</artifactId>
    <version>2.0.3</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/react-map-gl/
implementation 'org.webjars.npm:react-map-gl:2.0.3'
// https://jarcasting.com/artifacts/org.webjars.npm/react-map-gl/
implementation ("org.webjars.npm:react-map-gl:2.0.3")
'org.webjars.npm:react-map-gl:jar:2.0.3'
<dependency org="org.webjars.npm" name="react-map-gl" rev="2.0.3">
  <artifact name="react-map-gl" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='react-map-gl', version='2.0.3')
)
libraryDependencies += "org.webjars.npm" % "react-map-gl" % "2.0.3"
[org.webjars.npm/react-map-gl "2.0.3"]

Dependencies

compile (16)

Group / Artifact Type Version
org.webjars.npm : autobind-decorator jar [1.3.3,2)
org.webjars.npm : d3-format jar [1.0.2,2)
org.webjars.npm : d3-color jar [1.0.1,2)
org.webjars.npm : pure-render-decorator jar [1.1.0,2)
org.webjars.npm : mapbox-gl jar 0.32.1
org.webjars.npm : d3-selection jar [1.0.2,2)
org.webjars.npm : glob jar [7.1.1,8)
org.webjars.npm : viewport-mercator-project jar [2.0.1,3)
org.webjars.npm : global jar [4.3.0,5)
org.webjars.npm : d3-array jar [1.0.1,2)
org.webjars.npm : canvas-composite-types jar [1.0.4,2)
org.webjars.npm : d3-scale jar [1.0.3,2)
org.webjars.npm : d3-geo jar [1.2.4,2)
org.webjars.npm : svg-transform jar 0.0.3
org.webjars.npm : flow-remove-types jar [1.1.2,2)
org.webjars.npm : bowser jar [1.2.0,2)

Project Modules

There are no modules declared in this project.

version build downloads

react-map-gl | Docs

react-map-gl is a suite of React components designed to provide a React API for Mapbox GL JS-compatible libraries. More information in the online documentation.

See our Design Philosophy.

Installation

Using react-map-gl requires react >= 16.3.

npm install --save react-map-gl

Example

import * as React from 'react';
import ReactMapGL from 'react-map-gl';

function Map {
  const [viewport, setViewport] = React.useState({
    latitude: 37.7577,
    longitude: -122.4376,
    zoom: 8
  });

  return (
    <ReactMapGL
      {...viewport}
      width="100%"
      height="100%"
      onViewportChange={(viewport) => setViewport(viewport)}
    />
  );
}

Using Mapbox Tokens

Starting with v2.0, mapbox-gl requires a Mapbox token for any usage, with or without the Mapbox data service. See about Mapbox tokens for your options.

To show maps from a service such as Mapbox you will need to register on their website in order to retrieve an access token required by the map component, which will be used to identify you and start serving up map tiles. The service will be free until a certain level of traffic is exceeded.

There are several ways to provide a token to your app, as showcased in some of the example folders:

  • Provide a mapboxApiAccessToken prop to the map component
  • Set the MapboxAccessToken environment variable (or set REACT_APP_MAPBOX_ACCESS_TOKEN if you are using Create React App)
  • Provide it in the URL, e.g ?access_token=TOKEN
  • Provide mapboxApiUrl prop to the map component to override the default mapbox API URL

But we would recommend using something like dotenv and put your key in an untracked .env file, that will then expose it as a process.env variable, with much less leaking risks.

Limitations

This library provides convenient wrappers around initializing and (to some degree) tracking the state of a Mapbox WebGL map. Because most of the functionality of Mapbox's JS API depends on the use of HTML5 canvases and WebGL, which React is not built to manipulate, the React component does not mirror all the functionality of Mapbox GL JS's Map class. You may access the native Mapbox API exposed by the getMap() function in this library. However, proceed with caution as calling the native APIs may break the connection between the React layer props and the underlying map state.

Contribute

See contribution guide.

org.webjars.npm

Uber Open Source

Open Source Software at Uber

Versions

Version
2.0.3