MCPcopy
hub / github.com/keplergl/kepler.gl

github.com/keplergl/kepler.gl @v3.3.0-alpha.1 sqlite

repository ↗ · DeepWiki ↗ · release v3.3.0-alpha.1 ↗
4,879 symbols 13,037 edges 1,217 files 320 documented · 7%
README

version build stars MIT License Fossa Netlify Status Coverage Status

kepler.gl | Website | Demo App | Docs

Kepler.gl

Kepler.gl Demo

[Kepler.gl][web] is a data-agnostic, high-performance web-based application for visual exploration of large-scale geolocation data sets. Built on top of MapLibre GL and deck.gl, kepler.gl can render millions of points representing thousands of trips and perform spatial aggregations on the fly.

Kepler.gl is also a React component that uses Redux to manage its state and data flow. It can be embedded into other React-Redux applications and is highly customizable. For information on how to embed kepler.gl in your app take a look at the documentation.

Links

  • [Website][web]
  • [Demo][demo-app]
  • [Examples][examples]
  • [Get Started][get-started]
  • [App User Guide][user-guide]
  • [Jupyter Widget User Guide][user-guide-jupyter]
  • [Documentation][docs]
  • [Stack Overflow][stack]
  • [Contribution Guidelines][contributing]
  • [Api Reference][api-reference]
  • [Roadmap][roadmap]

Env

For developing this repository, use Node 20.19.3 (see .nvmrc): run nvm install and nvm use. Newer Node versions can make yarn install / yarn bootstrap try to compile the gl dev dependency from source; if that fails, see Troubleshooting: gl package install.

When using kepler.gl as a dependency in your own app, use Node 20.19.3 or a supported LTS; older Node versions are not supported or tested.

Install kepler.gl modules

Kepler.gl consists of different modules. Each module can be added to the project like this:

npm install --save @kepler.gl/components
// or
yarn add @kepler.gl/components

kepler.gl is built upon [mapbox][mapbox]. You will need a [Mapbox Access Token][mapbox-token] to use it.

If you don't use a module bundler, it's also fine. Kepler.gl npm package includes precompiled production UMD builds in the umd folder. You can add the script tag to your html file as it follows (latest version of Kepler.gl):

<script src="https://unpkg.com/kepler.gl/umd/keplergl.min.js" />

or if you would like, you can load a specific version:

<script src="https://unpkg.com/kepler.gl@3.0.0/umd/keplergl.min.js" />

Develop kepler.gl

Take a look at the [development guide][developers] to develop kepler.gl locally.

Basic Usage

Here are the basic steps to import kepler.gl into your app. You also take a look at the examples folder. Each example in the folder can be installed and run locally.

1. Mount reducer

Kepler.gl uses Redux to manage its internal state, along with [react-palm][react-palm] middleware to handle side effects.

You need to add taskMiddleware of react-palm to your store too. We are actively working on a solution where react-palm will not be required, however it is still a very lightweight side effects management tool that is easier to test than react-thunk.

import {createStore, combineReducers, applyMiddleware, compose} from 'redux';
import keplerGlReducer from '@kepler.gl/reducers';
import {enhanceReduxMiddleware} from '@kepler.gl/middleware';

const initialState = {};
const reducers = combineReducers({
  // <-- mount kepler.gl reducer in your app
  keplerGl: keplerGlReducer,

  // Your other reducers here
  app: appReducer
});

// using createStore
export default createStore(
  reducer,
  initialState,
  applyMiddleware(
    enhanceReduxMiddleware([
      /* Add other middlewares here */
    ])
  )
);

Or if use enhancer:

// using enhancers
const initialState = {};
const middlewares = enhanceReduxMiddleware([
  // Add other middlewares here
]);
const enhancers = [applyMiddleware(...middlewares)];

export default createStore(reducer, initialState, compose(...enhancers));

If you mount kepler.gl reducer in another address instead of keplerGl, or the kepler.gl reducer is not mounted at root of your state, you will need to specify the path to it when you mount the component with the getState prop.

Read more about [Reducers][reducers].

2. Mount Component

import KeplerGl from '@kepler.gl/components';

const Map = props => (
  <KeplerGl id="foo" width={width} mapboxApiAccessToken={token} height={height} />
);

Props

Prop Name Type Default Value Description
id String map The unique identifier for the KeplerGl instance. Required when multiple KeplerGl instances exist. It maps to the state in the reducer (e.g. component with id foo can be found instate.keplerGl.foo).
mapboxApiAccessToken String undefined API token for Mapbox, used for rendering base maps. Create a free token at Mapbox.
getState Function state => state.keplerGl Function that specifies the path to the root KeplerGl state in the reducer.
width Number 800 The width of the KeplerGl UI in pixels.
height Number 800 The height of the KeplerGl UI in pixels.
appName String Kepler.Gl The app name displayed in the side panel header.
version String v1.0 The version displayed in the side panel header.
onSaveMap Function undefined A function called when the "Save Map URL" in side panel header is clicked.
onViewStateChange Function undefined Triggered when the map viewport is updated. Receives viewState parameter with updated values like longitude, latitude, zoom, etc.
getMapboxRef(mapbox, index) Function undefined Called when KeplerGl adds or removes a MapContainer with an inner Mapbox map. mapbox is a MapRef when added, or null when removed. index is 0 for the first map and 1 for the second map in a split view.
actions Object {} Custom action creators to override the default KeplerGl action creators. Only use custom action when you want to modify action payload.
mint Boolean true Determines whether to load a fresh empty state when mounted. When false, the state persists across remounts. Useful for modal use cases.
theme Object/String null Set to "dark", "light", or "base", or pass a theme object to customize KeplerGl’s style.
mapboxApiUrl String https://api.mapbox.com The Mapbox API URL if you are using a custom Mapbox tile server.
mapStylesReplaceDefault Boolean false Set to true to replace default map styles with custom ones. (see mapStyles prop)
mapStyles Array [] An array of custom map styles for the map style selection panel. Styles replace the default ones if mapStylesReplaceDefault is true.
initialUiState Object undefined The initial UI state applied to the uiState reducer.
localeMessages Object undefined Used to modify or add new translations. Read more about [Localization][localization].

Example Custom Map Style

You can supply additional map styles to be displayed in map style selection panel. By default, additional map styles will be added to default map styles. If you pass mapStylesReplaceDefault: true, they will replace the default ones. kepler.gl will attempt to group layers of your style based on its id naming convention and use it to allow toggle visibility of base map layers. Supply your own layerGroups to override default for more accurate layer grouping.

Each mapStyles should has the following properties:

  • id (String, required) unique string that should not be one of these reserved dark light muted. muted_night
  • label (String, required) name to be displayed in map style selection panel
  • url (String, required) mapbox style url or a url pointing to the map style json object written in Mapbox GL Style Spec.
  • icon (String, optional) image icon of the style, it can be a url, or an image data url
  • layerGroups (Array, optional)
const mapStyles = [
  {
    id: 'my_dark_map',
    label: 'Dark Streets 9',
    url: 'mapbox://styles/mapbox/dark-v9',
    icon: `${apiHost}/styles/v1/mapbox/dark-v9/static/-122.3391,37.7922,9.19,0,0/400x300?access_token=${accessToken}&logo=false&attribution=false`,
    layerGroups: [
      {
        slug: 'label',
        filter: ({id}) => id.match(/(?=(label|place-|poi-))/),
        defaultVisibility: true
      },
      {
        slug: '3d building',
        filter: () => false,
        defaultVisibility: false
      }
    ]
  }
];

3. Dispatch custom actions to keplerGl reducer.

One advantage of using the reducer over React component state to handle keplerGl state is the flexibility to customize its behavior. If you only have one KeplerGl instance

Extension points exported contracts — how you extend this code

ComposedReducerSchema (Interface)
(no doc) [18 implementers]
src/schemas/src/schema-manager.ts
DataContainerInterface (Interface)
(no doc) [4 implementers]
src/utils/src/data-container-interface.ts
ArrowTableInterface (Interface)
(no doc) [3 implementers]
src/types/types.d.ts
StyledBarProps (Interface)
@typedef {import('./progress-bar').ProgressBarProps} ProgressBarProps
src/components/src/common/progress-bar.tsx
LightingEffectPrivate (Interface)
* Exposes private members of LightingEffect that we need to access. * These are runtime-accessible but TypeScript marks
src/effects/src/custom-deck-lighting-effect.ts
WebGLTextureFormat (Interface)
* Describe WebGL2 Texture parameters to use for given input data type
src/layers/src/raster-tile/gpu-utils.ts
LumaDevice (Interface)
luma.gl device interface for texture creation
src/deckgl-layers/src/raster/images.ts
IKeplerGlAction (Interface)
(no doc)
src/actions/src/action-wrapper.ts

Core symbols most depended-on inside this repo

find
called by 937
src/utils/src/data-container-interface.ts
map
called by 731
src/utils/src/data-container-interface.ts
reduce
called by 193
src/utils/src/data-container-interface.ts
valueAt
called by 143
src/utils/src/data-container-interface.ts
mountWithTheme
called by 118
test/helpers/component-utils.js
values
called by 86
src/utils/src/data-row.ts
setState
called by 76
src/deckgl-layers/src/layer-utils/cpu-aggregator.ts
applyActions
called by 72
test/helpers/mock-state-utils.js

Shape

Function 2,713
Method 1,303
Class 607
Interface 245
Enum 11

Languages

TypeScript97%
Python3%

Modules by API surface

src/reducers/src/vis-state-updaters.ts127 symbols
src/layers/src/base-layer.ts87 symbols
src/schemas/src/vis-state-schema.ts79 symbols
src/actions/src/vis-state-actions.ts79 symbols
bindings/python/tests/test_html_export.py67 symbols
src/utils/src/filter-utils.ts50 symbols
src/deckgl-layers/src/layer-utils/cpu-aggregator.ts48 symbols
src/layers/src/trip-layer/trip-layer.ts44 symbols
src/types/stac.d.ts42 symbols
src/utils/src/dom-utils.ts39 symbols
src/reducers/src/vis-state-merger.ts37 symbols
src/layers/src/aggregation-layer.ts37 symbols

Dependencies from manifests, versioned

@ai-sdk/anthropic1.2.11 · 1×
@ai-sdk/deepseek0.2.14 · 1×
@ai-sdk/google1.2.18 · 1×
@ai-sdk/xai1.2.16 · 1×
@anywidget/types0.2.0 · 1×
@auth0/auth0-spa-js2.1.2 · 1×
@babel/cli7.12.1 · 1×
@babel/core7.12.1 · 1×
@babel/eslint-parser7.17.0 · 1×
@babel/node7.12.1 · 1×
@babel/parser7.12.1 · 1×
@babel/plugin-transform-class-properties7.12.1 · 1×

For agents

$ claude mcp add kepler.gl \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact