All Projects → urbica → React Map Gl

urbica / React Map Gl

Licence: mit
React Component Library for Mapbox GL JS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Map Gl

React Map Gl
React friendly API wrapper around MapboxGL JS
Stars: ✭ 6,244 (+1995.3%)
Mutual labels:  webgl, mapbox-gl, mapbox-gl-js, data-visualization, map
angular-mapboxgl-directive
AngularJS directive for Mapbox GL
Stars: ✭ 43 (-85.57%)
Mutual labels:  map, webgl, mapbox-gl, mapbox-gl-js
Mapbox Gl Js
Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL
Stars: ✭ 8,017 (+2590.27%)
Mutual labels:  webgl, mapbox-gl, mapbox-gl-js, map
react-map-gl-cluster
Urbica React Cluster Component for Mapbox GL JS
Stars: ✭ 27 (-90.94%)
Mutual labels:  map, mapbox-gl, mapbox-gl-js
L7
🌎 Large-scale WebGL-powered Geospatial Data Visualization analysis framework which relies on Mapbox GL or AMap to render basemaps.
Stars: ✭ 2,517 (+744.63%)
Mutual labels:  webgl, data-visualization, map
React Mapbox Gl
A React binding of mapbox-gl-js
Stars: ✭ 1,683 (+464.77%)
Mutual labels:  mapbox-gl, mapbox-gl-js, map
Dc Sdk
DC-SDK 是基于 Cesium 进行二次开发的2、3D一体 WebGis 应用框架,该框架优化了 Cesium 的使用方式和增添了一些额外功能,旨在为开发者快速构建 WebGis 应用。🌎
Stars: ✭ 206 (-30.87%)
Mutual labels:  webgl, map
Ol3echarts
🌏 📊 ol3Echarts | a openlayers extension to echarts
Stars: ✭ 229 (-23.15%)
Mutual labels:  webgl, map
Glmaps
Data visualization examples and tutorials from scratch. 数据可视化示例代码集与新手学习教程。
Stars: ✭ 288 (-3.36%)
Mutual labels:  webgl, data-visualization
react-map-gl-draw
React Component for Mapbox GL Draw
Stars: ✭ 50 (-83.22%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Plotly.js
Open-source JavaScript charting library behind Plotly and Dash
Stars: ✭ 14,268 (+4687.92%)
Mutual labels:  webgl, data-visualization
Rthreejs
Three.js widgets for R and shiny
Stars: ✭ 251 (-15.77%)
Mutual labels:  webgl, data-visualization
Mapdeck
R interface to Deck.gl and Mapbox
Stars: ✭ 296 (-0.67%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Openglobus
JavaScript 3d maps and geospatial data visualization engine library.
Stars: ✭ 199 (-33.22%)
Mutual labels:  webgl, map
Plotly Graphing Library For Matlab
Plotly Graphing Library for MATLAB®
Stars: ✭ 234 (-21.48%)
Mutual labels:  webgl, data-visualization
Droneworld
droneWorld: a 3D world map and a three.js playground
Stars: ✭ 197 (-33.89%)
Mutual labels:  webgl, map
deck.gl-time-series-widget
A React Time Slider implementation for DECK.GL - (non)temporal data - by CPU filtering ⌛
Stars: ✭ 19 (-93.62%)
Mutual labels:  mapbox-gl, mapbox-gl-js
who-owns-what
Who owns what in nyc?
Stars: ✭ 146 (-51.01%)
Mutual labels:  mapbox-gl, mapbox-gl-js
react-mapboxgl
Declarative React components for mapbox-gl-js.
Stars: ✭ 15 (-94.97%)
Mutual labels:  mapbox-gl, mapbox-gl-js
Tangram
WebGL map rendering engine for creative cartography
Stars: ✭ 1,964 (+559.06%)
Mutual labels:  webgl, map

Urbica React Mapbox GL JS

Node CI codecov npm npm npm bundle size (scoped)

React Component Library for Mapbox GL JS. Mapbox GL JS is a JavaScript library that renders interactive maps from vector tiles and Mapbox styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.

This project is heavily inspired by uber/react-map-gl.

Gallery

Installation

npm install --save mapbox-gl @urbica/react-map-gl

...or if you are using yarn:

yarn add mapbox-gl @urbica/react-map-gl

Optional Dependencies

If you want to use the LanguageControl:

npm install --save @mapbox/mapbox-gl-language

...or if you are using yarn:

yarn add @mapbox/mapbox-gl-language

Components

Component Description
MapGL Represents map on the page
MapContext React Context API for the map instance
Source Sources specify the geographic features to be rendered on the map
Layer Layers specify the Sources style
Filter Set filter to existing layer
CustomLayer Allow a user to render directly into the map's GL context
Image Adds an image to the map style
Popup React Component for Mapbox GL JS Popup
Marker React Component for Mapbox GL JS Marker
FeatureState Sets the state of a geographic feature rendered on the map
AttributionControl Represents the map's attribution information
LanguageControl Adds support for switching the language of the map style
FullscreenControl Contains a button for toggling the map in and out of fullscreen mode
GeolocateControl Geolocate the user and then track their current location on the map
NavigationControl Contains zoom buttons and a compass
ScaleControl Displays the ratio of a distance on the map to the corresponding distance on the ground
Cluster Cluster Markers with supercluster
Draw Support for drawing and editing features

Usage

To use any of Mapbox’s tools, APIs, or SDKs, you’ll need a Mapbox access token. Mapbox uses access tokens to associate requests to API resources with your account. You can find all your access tokens, create new ones, or delete existing ones on your API access tokens page.

See Documentation for more examples.

Static Map

By default, MapGL component renders in a static mode. That means that the user cannot interact with the map.

import React from 'react';
import MapGL from '@urbica/react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

<MapGL
  style={{ width: '100%', height: '400px' }}
  mapStyle='mapbox://styles/mapbox/light-v9'
  accessToken={MAPBOX_ACCESS_TOKEN}
  latitude={37.78}
  longitude={-122.41}
  zoom={11}
/>;

Interactive Map

In most cases, you will want the user to interact with the map. To do this, you need to provide onViewportChange handler, that will update map viewport state.

import React, { useState } from 'react';
import MapGL from '@urbica/react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

const [viewport, setViewport] = useState({
  latitude: 37.78,
  longitude: -122.41,
  zoom: 11
});

<MapGL
  style={{ width: '100%', height: '400px' }}
  mapStyle='mapbox://styles/mapbox/light-v9'
  accessToken={MAPBOX_ACCESS_TOKEN}
  latitude={viewport.latitude}
  longitude={viewport.longitude}
  zoom={viewport.zoom}
  onViewportChange={setViewport}
/>;

MapGL with Source and Layer

Sources specify the geographic features to be rendered on the map.

Layers specify the Sources styles. The type of layer is specified by the "type" property, and must be one of background, fill, line, symbol, raster, circle, fill-extrusion, heatmap, hillshade.

Except for layers of the background type, each layer needs to refer to a source. Layers take the data that they get from a source, optionally filter features, and then define how those features are styled.

import React from 'react';
import MapGL, { Source, Layer } from '@urbica/react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

<MapGL
  style={{ width: '100%', height: '400px' }}
  mapStyle='mapbox://styles/mapbox/light-v9'
  accessToken={MAPBOX_ACCESS_TOKEN}
>
  <Source id='contours' type='vector' url='mapbox://mapbox.mapbox-terrain-v2' />
  <Layer
    id='contours'
    type='line'
    source='contours'
    source-layer='contour'
    paint={{
      'line-color': '#877b59',
      'line-width': 1
    }}
  />
</MapGL>;

MapGL with GeoJSON Source

To draw a GeoJSON on a map, add Source with the type property set to geojson and data property set to a URL or inline GeoJSON.

import React, { useState } from 'react';
import MapGL, { Source, Layer } from '@urbica/react-map-gl';
import 'mapbox-gl/dist/mapbox-gl.css';

const [viewport, setViewport] = useState({
  latitude: 37.830348,
  longitude: -122.486052,
  zoom: 15
});

const data = {
  type: 'Feature',
  geometry: {
    type: 'LineString',
    coordinates: [
      [-122.48369693756104, 37.83381888486939],
      [-122.48348236083984, 37.83317489144141],
      [-122.48339653015138, 37.83270036637107],
      [-122.48356819152832, 37.832056363179625],
      [-122.48404026031496, 37.83114119107971],
      [-122.48404026031496, 37.83049717427869],
      [-122.48348236083984, 37.829920943955045],
      [-122.48356819152832, 37.82954808664175],
      [-122.48507022857666, 37.82944639795659],
      [-122.48610019683838, 37.82880236636284],
      [-122.48695850372314, 37.82931081282506],
      [-122.48700141906738, 37.83080223556934],
      [-122.48751640319824, 37.83168351665737],
      [-122.48803138732912, 37.832158048267786],
      [-122.48888969421387, 37.83297152392784],
      [-122.48987674713133, 37.83263257682617],
      [-122.49043464660643, 37.832937629287755],
      [-122.49125003814696, 37.832429207817725],
      [-122.49163627624512, 37.832564787218985],
      [-122.49223709106445, 37.83337825839438],
      [-122.49378204345702, 37.83368330777276]
    ]
  }
};

<MapGL
  style={{ width: '100%', height: '400px' }}
  mapStyle='mapbox://styles/mapbox/light-v9'
  accessToken={MAPBOX_ACCESS_TOKEN}
  onViewportChange={setViewport}
  {...viewport}
>
  <Source id='route' type='geojson' data={data} />
  <Layer
    id='route'
    type='line'
    source='route'
    layout={{
      'line-join': 'round',
      'line-cap': 'round'
    }}
    paint={{
      'line-color': '#888',
      'line-width': 8
    }}
  />
</MapGL>;

Custom Layers support

Custom layers allow a user to render directly into the map's GL context using the map's camera.

Here is an Uber deck.gl usage example.

import React from 'react';
import MapGL, { CustomLayer } from '@urbica/react-map-gl';
import { MapboxLayer } from '@deck.gl/mapbox';
import { ScatterplotLayer } from '@deck.gl/layers';
import 'mapbox-gl/dist/mapbox-gl.css';

const myDeckLayer = new MapboxLayer({
  id: 'my-scatterplot',
  type: ScatterplotLayer,
  data: [{ position: [-74.5, 40], size: 1000 }],
  getPosition: (d) => d.position,
  getRadius: (d) => d.size,
  getColor: [255, 0, 0]
});

<MapGL
  style={{ width: '100%', height: '400px' }}
  mapStyle='mapbox://styles/mapbox/light-v9'
  accessToken={MAPBOX_ACCESS_TOKEN}
  latitude={40}
  longitude={-74.5}
  zoom={9}
>
  <CustomLayer layer={myDeckLayer} />
</MapGL>;

Documentation

Check out documentation website.

Changelog

Check out CHANGELOG.md and releases page.

License

This project is licensed under the terms of the MIT license.

Contributing

Clone and install dependencies

git clone https://github.com/urbica/react-map-gl.git
cd react-map-gl
npm install

Start react-styleguidist server

MAPBOX_ACCESS_TOKEN=<TOKEN> npm start

where <TOKEN> is a valid Mapbox access token.

Run tests with

npm test

Team

Stepan Kuzmin Artem Boyur Andrey Bakhvalov
Stepan Kuzmin Artem Boyur Andrey Bakhvalov
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].