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

map-state

Previousmap-styleNextcombine

Last updated 6 months ago

Was this helpful?

Table of Contents

mapStateUpdaters

Updaters for mapState reducer. Can be used in your root reducer to directly modify kepler.gl's state. Read more about

Examples

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

const composedReducer = (state, action) => {
 switch (action.type) {
   // click button to close side panel
   case 'CLICK_BUTTON':
     return {
       ...state,
       keplerGl: {
         ...state.keplerGl,
         foo: {
            ...state.keplerGl.foo,
            mapState: mapStateUpdaters.fitBoundsUpdater(
              mapState, {payload: [127.34, 31.09, 127.56, 31.59]]}
            )
         }
       }
     };
 }
 return reducers(state, action);
};

export default composedReducer;

fitBoundsUpdater

Fit map viewport to bounds

Parameters

INITIAL_MAP_STATE

Default initial mapState

Properties

receiveMapConfigUpdater

Update mapState to propagate a new config

Parameters

    • action.payload.config (optional, default {})

    • action.payload.options (optional, default {})

    • action.payload.bounds (optional, default null)

resetMapConfigUpdater

reset mapState to initial State

Parameters

togglePerspectiveUpdater

Toggle between 3d and 2d map.

Parameters

toggleSplitMapUpdater

Toggle between one or split maps

Parameters

updateMapUpdater

Update map viewport

Parameters

Action:

state

action

action.payload <> bounds as [lngMin, latMin, lngMax, latMax]

Returns nextState

pitch Default: 0

bearing Default: 0

latitude Default: 37.75043

longitude Default: -122.34679

zoom Default: 9

dragRotate Default: false

width Default: 800

height Default: 800

isSplit Default: false

Action:

state

action

action.payload saved map config

Returns nextState

Action:

state mapState

Returns nextState

Action:

state

Returns nextState

Action:

state

Returns nextState

Action:

state

action

action.payload viewport

Returns nextState

Object
Object
Array
number
Object
number
number
number
number
number
boolean
number
number
boolean
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Object
Using updaters
mapStateUpdaters
fitBoundsUpdater
INITIAL_MAP_STATE
Properties
receiveMapConfigUpdater
resetMapConfigUpdater
togglePerspectiveUpdater
toggleSplitMapUpdater
updateMapUpdater
fitBounds
receiveMapConfig
resetMapConfig
togglePerspective
toggleSplitMap
updateMap