Convert Figma logo to code with AI

visgl logodeck.gl

WebGL2 powered visualization framework

12,048
2,076
12,048
341

Top Related Projects

React friendly API wrapper around MapboxGL JS

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

40,934

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

OpenLayers

12,690

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:

101,622

JavaScript 3D Library.

Quick Overview

deck.gl is a powerful and flexible WebGL-based visualization framework for large-scale datasets. Developed by Uber, it's designed to render millions of points efficiently in the browser, making it ideal for geospatial visualizations, 3D charts, and other data-intensive applications.

Pros

  • High performance rendering of large datasets
  • Extensive collection of customizable layers for various visualization types
  • Seamless integration with React and other web frameworks
  • Strong ecosystem and active community support

Cons

  • Steep learning curve for beginners
  • Limited documentation for advanced use cases
  • Performance can degrade with extremely large datasets on low-end devices
  • Some features require additional dependencies or plugins

Code Examples

  1. Creating a simple scatterplot layer:
import {Deck} from '@deck.gl/core';
import {ScatterplotLayer} from '@deck.gl/layers';

const deck = new Deck({
  initialViewState: {
    longitude: -122.4,
    latitude: 37.8,
    zoom: 11
  },
  layers: [
    new ScatterplotLayer({
      data: [
        {position: [-122.45, 37.78], color: [255, 0, 0], radius: 100}
      ],
      getPosition: d => d.position,
      getColor: d => d.color,
      getRadius: d => d.radius
    })
  ]
});
  1. Adding a heatmap layer:
import {HeatmapLayer} from '@deck.gl/aggregation-layers';

const heatmapLayer = new HeatmapLayer({
  id: 'heatmap-layer',
  data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/screen-grid/uber-pickup-locations.json',
  getPosition: d => [d[0], d[1]],
  getWeight: d => d[2],
  radiusPixels: 60
});
  1. Creating a 3D hexagon layer:
import {HexagonLayer} from '@deck.gl/aggregation-layers';

const hexagonLayer = new HexagonLayer({
  id: 'hexagon-layer',
  data: 'https://raw.githubusercontent.com/visgl/deck.gl-data/master/examples/3d-heatmap/heatmap-data.csv',
  extruded: true,
  radius: 1000,
  elevationScale: 100,
  getPosition: d => [d.lng, d.lat]
});

Getting Started

To get started with deck.gl, follow these steps:

  1. Install deck.gl and its dependencies:

    npm install deck.gl @deck.gl/core @deck.gl/layers
    
  2. Create a basic deck.gl application:

    import {Deck} from '@deck.gl/core';
    import {ScatterplotLayer} from '@deck.gl/layers';
    
    const deck = new Deck({
      container: 'map-container',
      initialViewState: {
        longitude: -122.4,
        latitude: 37.8,
        zoom: 11
      },
      layers: [
        new ScatterplotLayer({
          data: [
            {position: [-122.45, 37.78], color: [255, 0, 0], radius: 100}
          ],
          getPosition: d => d.position,
          getColor: d => d.color,
          getRadius: d => d.radius
        })
      ]
    });
    
  3. Add the necessary HTML and CSS to display the map.

For more detailed instructions and advanced usage, refer to the official deck.gl documentation.

Competitor Comparisons

React friendly API wrapper around MapboxGL JS

Pros of react-map-gl

  • Simpler API and easier learning curve for React developers
  • Lightweight and focused specifically on Mapbox GL integration
  • Better suited for basic mapping needs without extensive data visualization

Cons of react-map-gl

  • Limited built-in data visualization capabilities
  • Less flexibility for advanced custom layers and 3D visualizations
  • Smaller ecosystem of extensions and plugins compared to deck.gl

Code Comparison

react-map-gl:

import Map from 'react-map-gl';

function MyMap() {
  return <Map
    initialViewState={{longitude: -122.4, latitude: 37.8, zoom: 14}}
    style={{width: 600, height: 400}}
    mapStyle="mapbox://styles/mapbox/streets-v9"
  />;
}

deck.gl:

import DeckGL from '@deck.gl/react';
import {ScatterplotLayer} from '@deck.gl/layers';

function MyDeckGLMap() {
  const layers = [
    new ScatterplotLayer({id: 'scatter', data, getPosition: d => d.position, ...})
  ];
  return <DeckGL initialViewState={{longitude: -122.4, latitude: 37.8, zoom: 14}}
                 layers={layers} />;
}

Both libraries offer React components for mapping, but deck.gl provides more advanced data visualization capabilities out of the box, while react-map-gl focuses on simpler Mapbox GL integration. deck.gl is better suited for complex data visualizations and custom layers, while react-map-gl is more appropriate for basic mapping needs with a gentler learning curve.

Interactive, thoroughly customizable maps in the browser, powered by vector tiles and WebGL

Pros of mapbox-gl-js

  • More comprehensive mapping features, including built-in geocoding and directions
  • Extensive documentation and large community support
  • Seamless integration with Mapbox's ecosystem and services

Cons of mapbox-gl-js

  • Requires a Mapbox account and API key for full functionality
  • Less flexibility for custom data visualization compared to deck.gl
  • Heavier library size, which may impact load times for simpler applications

Code Comparison

mapbox-gl-js:

mapboxgl.accessToken = 'YOUR_MAPBOX_ACCESS_TOKEN';
const map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/streets-v11',
  center: [-74.5, 40],
  zoom: 9
});

deck.gl:

const deckgl = new Deck({
  initialViewState: {
    longitude: -74.5,
    latitude: 40,
    zoom: 9
  },
  layers: [
    new ScatterplotLayer({/* layer props */})
  ]
});

Summary

mapbox-gl-js is a robust mapping library with extensive features and documentation, ideal for projects requiring traditional mapping capabilities. It integrates well with Mapbox services but requires an API key. deck.gl, on the other hand, offers more flexibility for custom data visualizations and doesn't require a specific map provider, making it suitable for complex data-driven applications. The choice between the two depends on the specific needs of your project, such as the level of customization required and the importance of built-in mapping features.

40,934

πŸƒ JavaScript library for mobile-friendly interactive maps πŸ‡ΊπŸ‡¦

Pros of Leaflet

  • Lightweight and easy to learn, with a simple API
  • Extensive plugin ecosystem for additional functionality
  • Better support for traditional tile-based maps

Cons of Leaflet

  • Limited support for large datasets and complex visualizations
  • Less suitable for 3D and WebGL-based rendering

Code Comparison

Leaflet:

var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
L.marker([51.5, -0.09]).addTo(map).bindPopup('A sample marker.');

deck.gl:

const deckgl = new Deck({
  initialViewState: {longitude: -0.09, latitude: 51.505, zoom: 13},
  layers: [
    new ScatterplotLayer({data: [{position: [-0.09, 51.5]}], getRadius: 100})
  ]
});

Leaflet focuses on simplicity and ease of use for traditional map interactions, while deck.gl excels in handling large datasets and creating complex, WebGL-powered visualizations. Leaflet is more suitable for projects requiring basic mapping functionality, whereas deck.gl is better for data-intensive applications and advanced visual effects.

OpenLayers

Pros of OpenLayers

  • More mature and established library with a larger community and extensive documentation
  • Supports a wider range of map projections and coordinate systems
  • Better suited for traditional 2D mapping applications and GIS functionality

Cons of OpenLayers

  • Less optimized for rendering large datasets and complex visualizations
  • Limited support for 3D and WebGL-based rendering
  • Steeper learning curve for beginners due to its comprehensive feature set

Code Comparison

OpenLayers:

import Map from 'ol/Map';
import View from 'ol/View';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';

const map = new Map({
  layers: [new TileLayer({ source: new OSM() })],
  target: 'map',
  view: new View({ center: [0, 0], zoom: 2 })
});

deck.gl:

import {Deck} from '@deck.gl/core';
import {GeoJsonLayer} from '@deck.gl/layers';

const deck = new Deck({
  initialViewState: {longitude: 0, latitude: 0, zoom: 2},
  layers: [new GeoJsonLayer({data: 'https://example.com/geojson.json'})]
});

Both libraries offer powerful mapping capabilities, but they cater to different use cases. OpenLayers excels in traditional mapping and GIS applications, while deck.gl is better suited for high-performance data visualization and WebGL-based rendering.

12,690

An open-source JavaScript library for world-class 3D globes and maps :earth_americas:

Pros of Cesium

  • Specialized for 3D geospatial visualization and globe rendering
  • Robust support for various geospatial data formats and standards
  • Built-in time-dynamic visualization capabilities

Cons of Cesium

  • Steeper learning curve for non-GIS developers
  • Heavier initial load time due to comprehensive feature set
  • Less flexibility for non-geospatial data visualizations

Code Comparison

Cesium example:

const viewer = new Cesium.Viewer('cesiumContainer');
viewer.dataSources.add(Cesium.GeoJsonDataSource.load('data.geojson'));

deck.gl example:

const deckgl = new Deck({
  layers: [
    new GeoJsonLayer({
      id: 'geojson-layer',
      data: 'data.geojson',
      filled: true,
      extruded: true
    })
  ]
});

Both libraries offer ways to load and visualize GeoJSON data, but Cesium's approach is more focused on geospatial rendering, while deck.gl provides a more flexible layering system for various data types.

Cesium excels in 3D globe visualizations and handling complex geospatial data, making it ideal for Earth-centric applications. deck.gl, on the other hand, offers greater flexibility for general-purpose data visualization, including non-geospatial use cases, and integrates well with React and other web frameworks.

101,622

JavaScript 3D Library.

Pros of Three.js

  • More versatile for general 3D graphics and animations
  • Larger community and ecosystem with extensive documentation
  • Supports a wider range of 3D objects and geometries

Cons of Three.js

  • Steeper learning curve for beginners
  • Less optimized for large-scale data visualization
  • Requires more manual setup for data-driven visualizations

Code Comparison

Three.js (basic scene setup):

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

Deck.gl (basic layer setup):

const deck = new Deck({
  initialViewState: {
    longitude: -122.4,
    latitude: 37.8,
    zoom: 12
  },
  layers: [
    new ScatterplotLayer({
      data: [
        {position: [-122.4, 37.8], color: [255, 0, 0], radius: 100}
      ]
    })
  ]
});

Three.js is better suited for complex 3D scenes and animations, while Deck.gl excels in large-scale data visualization and geospatial applications. Three.js offers more flexibility but requires more setup, whereas Deck.gl provides a more streamlined approach for specific use cases.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

version build downloads Coverage Status

deck.gl | Website

GPU-powered, highly performant large-scale data visualization

docs

deck.gl is designed to simplify high-performance, WebGL2/WebGPU based visualization of large data sets. Users can quickly get impressive visual results with minimal effort by composing existing layers, or leverage deck.gl's extensible architecture to address custom needs.

deck.gl maps data (usually an array of JSON objects) into a stack of visual layers - e.g. icons, polygons, texts; and look at them with views: e.g. map, first-person, orthographic.

deck.gl handles a number of challenges out of the box:

  • Performant rendering and updating of large data sets
  • Interactive event handling such as picking, highlighting and filtering
  • Cartographic projections and integration with major basemap providers
  • A catalog of proven, well-tested layers

Deck.gl is designed to be highly customizable. All layers come with flexible APIs to allow programmatic control of each aspect of the rendering. All core classes such are easily extendable by the users to address custom use cases.

Flavors

Script Tag

<script src="https://unpkg.com/deck.gl@latest/dist.min.js"></script>

NPM Module

npm install deck.gl

Pure JS

React

Python

pip install pydeck

Third-Party Goodies

Learning Resources

Contributing

deck.gl is part of vis.gl, an OpenJS Foundation project. Read the contribution guidelines if you are interested in contributing.

Attributions

Data sources

Data sources are listed in each example.

The deck.gl project is supported by

BrowserStack

NPM DownloadsLast 30 Days