LogoLogo
  • Welcome
  • What's new?
  • Docs
    • User guides
      • Get Started
      • Kepler.gl workflow
        • Add data to layers
          • Adding Data Layers
          • Create a Layer
          • Blend and Rearrange Layers
          • Hide, Edit and Delete Layers
        • Add Data to the Map
      • Layers
        • Point
        • S2 Layer
        • Icon
        • Line
        • Cluster
        • Polygon
        • Hexbin
        • Grid
        • H3
        • Heatmap
        • Arc
        • Trip layer
      • Layer Attributes
      • Color Palettes
      • Filters
      • Map Styles
      • Interactions
      • Map Settings
      • Time Playback
      • Save and Export
      • FAQ
    • API Reference
      • ecosystem
      • Get Started
      • Advanced usages
        • Saving and Loading Maps with Schema Manager
        • Replace UI Component with Component Dependency Injection
        • Forward Dispatch Actions
        • Reducer Plugin
        • Using Updaters
        • Custom reducer initial state
        • custom-mapbox-host
      • Components
      • Reducers
        • reducers
        • map-style
        • map-state
        • combine
        • overview
        • ui-state
        • vis-state
      • Processors
        • All processors
      • Schemas
      • Actions
        • All actions
      • Cloud providers
        • Provider
      • Custom theme
      • Localization
    • Jupyter Notebook
  • Examples
    • Node/Express
    • Demo App
    • Open modal
    • Open modal
    • UMD client
    • Customize kepler.gl Theme
    • Customize kepler.gl Reducer
  • Contributing
    • Developing Kepler.gl
    • Contributor Covenant Code of Conduct
  • Change Log
  • Upgrade Guide
Powered by GitBook
On this page

Was this helpful?

  1. Docs
  2. API Reference
  3. Reducers

combine

Previousmap-stateNextui-state

Last updated 6 months ago

Was this helpful?

Table of Contents

combinedUpdaters

Some actions will affect the entire kepler.lg instance state. The updaters for these actions is exported as combinedUpdaters. These updater take the entire instance state as the first argument. Read more about

Examples

import keplerGlReducer, {combinedUpdaters} from '@kepler.gl/reducers';
// Root Reducer
const reducers = combineReducers({
 keplerGl: keplerGlReducer,
 app: appReducer
});

const composedReducer = (state, action) => {
 switch (action.type) {
   // add data to map after receiving data from remote sources
   case 'LOAD_REMOTE_RESOURCE_SUCCESS':
     return {
       ...state,
       keplerGl: {
         ...state.keplerGl,
         // pass in kepler.gl instance state to combinedUpdaters
         map:  combinedUpdaters.addDataToMapUpdater(
          state.keplerGl.map,
          {
            payload: {
              datasets: action.datasets,
              options: {readOnly: true},
              config: action.config
             }
           }
         )
       }
     };
 }
 return reducers(state, action);
};

export default composedReducer;

addDataToMapUpdater

Combine data and full configuration update in a single action

Parameters

Action:

state kepler.gl instance state, containing all subreducer state

action

action.payload {datasets, options, config}

action.payload.datasets (<> | ) *required datasets can be a dataset or an array of datasets Each dataset object needs to have info and data property.

action.payload.datasets.info -info of a dataset

action.payload.datasets.info.id id of this dataset. If config is defined, id should matches the dataId in config.

action.payload.datasets.info.label A display name of this dataset

action.payload.datasets.data *required The data object, in a tabular format with 2 properties fields and rows

action.payload.datasets.data.fields <> *required Array of fields,

action.payload.datasets.data.fields.name *required Name of the field,

action.payload.datasets.data.rows <> *required Array of rows, in a tabular format with fields and rows

action.payload.options option object {centerMap: true}

action.payload.config map config

Returns nextState

Object
Object
Object
Array
Object
Object
Object
string
string
Object
Array
Object
string
Array
Array
Object
Object
Object
Using updaters
combinedUpdaters
addDataToMapUpdater
addDataToMap