All actions

Table of Contents

forwardActions

A set of helpers to forward dispatch actions to a specific instance reducer

forwardTo

Returns an action dispatcher that wraps and forwards the actions to a specific instance

Parameters

Examples

isForwardAction

Whether an action is a forward action

Parameters

Returns booleanarrow-up-right boolean - whether the action is a forward action

unwrap

Unwrap an action

Parameters

Returns Objectarrow-up-right unwrapped action

wrapTo

Wrap an action into a forward action that only modify the state of a specific kepler.gl instance. kepler.gl reducer will look for signatures in the action to determine whether it needs to be forwarded to a specific instance reducer.

wrapTo can be curried. You can create a curried action wrapper by only supply the id argument

A forward action looks like this

Parameters

Examples

ActionTypes

Kepler.gl action types, can be listened by reducers to perform additional tasks whenever an action is called in kepler.gl

Type: Objectarrow-up-right

Examples

mapStyleActions

Actions handled mostly by mapStyle reducer. They manage the display of base map, such as loading and receiving base map styles, hiding and showing map layers, user input of custom map style url.

addCustomMapStyle

Add map style from user input to reducer and set it to current style This action is called when user click confirm after putting in a valid style url in the custom map style dialog. It should not be called from outside kepler.gl without a valid inputStyle in the mapStyle reducer. param {void}

inputMapStyle

Input a custom map style object

Parameters

loadCustomMapStyle

Callback when a custom map style object is received

Parameters

loadMapStyleErr

Callback when load map style error

Parameters

  • error any

loadMapStyles

Callback when load map style success

Parameters

mapConfigChange

Update visibleLayerGroupsto change layer group visibility

Parameters

  • mapStyle Objectarrow-up-right new config {visibleLayerGroups: {label: false, road: true, background: true}}

mapStyleChange

Change to another map style. The selected style should already been loaded into mapStyle.mapStyles

Parameters

requestMapStyles

Request map style style object based on style.url.

Parameters

set3dBuildingColor

Set 3d building layer group color

Parameters

main

Main kepler.gl actions, these actions handles loading data and config into kepler.gl reducer. These actions is listened by all subreducers,

addDataToMap

Add data to kepler.gl reducer, prepare map with preset configuration if config is passed. Kepler.gl provides a handy set of utils to parse data from different formats to the data object required in dataset. You rarely need to manually format the data obejct.

Use KeplerGlSchema.getConfigToSave to generate a json blob of the currents instance config. The config object value will always have higher precedence than the options properties.

Kepler.gl uses dataId in the config to match with loaded dataset. If you pass a config object, you need to match the info.id of your dataset to the dataId in each layer, filter and interactionConfig.tooltips.fieldsToShow

Parameters

Examples

keplerGlInit

Initialize kepler.gl reducer. It is used to pass in mapboxApiAccessToken to mapStyle reducer.

Parameters

receiveMapConfig

Pass config to kepler.gl instance, prepare the state with preset configs. Calling KeplerGlSchema.parseSavedConfig to convert saved config before passing it in is required.

You can call receiveMapConfig before passing in any data. The reducer will store layer and filter config, waiting for data to come in. When data arrives, you can call addDataToMap without passing any config, and the reducer will try to match preloaded configs. This behavior is designed to allow asynchronous data loading.

It is also useful when you want to prepare the kepler.gl instance with some preset layer and filter settings. Note Sequence is important, receiveMapConfig needs to be called before data is loaded. Currently kepler.gl doesn't allow calling receiveMapConfig after data is loaded. It will reset current configuration first then apply config to it.

Parameters

Examples

resetMapConfig

Reset all sub-reducers to its initial state. This can be used to clear out all configuration in the reducer.

visStateActions

Actions handled mostly by visState reducer. They manage how data is processed, filtered and displayed on the map by operates on layers, filters and interaction settings.

addFilter

Add a new filter

Parameters

Returns {type: ActionTypes.ADD_FILTER, dataId: dataId}

addLayer

Add a new layer

Parameters

Returns {type: ActionTypes.ADD_LAYER, props: props}

applyCPUFilter

Trigger CPU filter of selected dataset

Parameters

Returns {type: ActionTypes.APPLY_CPU_FILTER, dataId: stringarrow-up-right}

enlargeFilter

Show larger time filter at bottom for time playback (apply to time filter only)

Parameters

Returns {type: ActionTypes.ENLARGE_FILTER, idx: idx}

interactionConfigChange

Update interactionConfig

Parameters

Returns {type: ActionTypes.INTERACTION_CONFIG_CHANGE, config: config}

layerConfigChange

Update layer base config: dataId, label, column, isVisible

Parameters

Returns {type: ActionTypes.LAYER_CONFIG_CHANGE, oldLayer: oldLayer, newConfig: newConfig}

layerTextLabelChange

Update layer text label

Parameters

layerTypeChange

Update layer type. Previews layer config will be copied if applicable.

Parameters

Returns {type: ActionTypes.LAYER_TYPE_CHANGE, oldLayer: oldLayer, newType: newType}

layerVisConfigChange

Update layer visConfig

Parameters

Returns {type: ActionTypes.LAYER_VIS_CONFIG_CHANGE, oldLayer: oldLayer, newVisConfig: newVisConfig}

layerVisualChannelConfigChange

Update layer visual channel

Parameters

Returns {type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE, oldLayer: oldLayer, newConfig: newConfig, channel: channel}

loadFiles

Trigger file loading dispatch addDataToMap if succeed, or loadFilesErr if failed

Parameters

Returns {type: ActionTypes.LOAD_FILES, files: any}

loadFilesErr

Trigger loading file error

Parameters

  • error any

Returns {type: ActionTypes.LOAD_FILES_ERR, error: Objectarrow-up-right}

onLayerClick

Trigger layer click event with clicked object

Parameters

Returns {type: ActionTypes.LAYER_CLICK, info: info}

onLayerHover

Trigger layer hover event with hovered object

Parameters

Returns {type: ActionTypes.LAYER_HOVER, info: info}

onMapClick

Trigger map click event, unselect clicked object

Returns {type: ActionTypes.MAP_CLICK}

onMouseMove

Trigger map mouse moveevent, payload would be React-map-gl MapLayerMouseEvent https://visgl.github.io/react-map-gl/docs/api-reference/types#maplayermouseeventarrow-up-right

Parameters

Returns {type: ActionTypes.MAP_CLICK}

removeDataset

Remove a dataset and all layers, filters, tooltip configs that based on it

Parameters

Returns {type: ActionTypes.REMOVE_DATASET, key: key}

removeFilter

Remove a filter from visState.filters, once a filter is removed, data will be re-filtered and layer will be updated

Parameters

Returns {type: ActionTypes.REMOVE_FILTER, idx: idx}

removeLayer

Remove a layer

Parameters

Returns {type: ActionTypes.REMOVE_LAYER, idx: idx}

reorderLayer

Reorder layer, order is an array of layer indexes, index 0 will be the one at the bottom

Parameters

Examples

Returns {type: ActionTypes.REORDER_LAYER, order: order}

setEditorMode

Set the map mode

Parameters

Examples

setFilter

Update filter property

Parameters

Returns {type: ActionTypes.SET_FILTER, idx: idx, prop: prop, value: value}

setFilterPlot

Set the property of a filter plot

Parameters

Returns {type: ActionTypes.SET_FILTER_PLOT, idx: any, newProp: any}

setMapInfo

Set the property of a filter plot

Parameters

Returns {type: ActionTypes.SET_FILTER_PLOT, idx: any, newProp: any}

showDatasetTable

Display dataset table in a modal

Parameters

Returns {type: ActionTypes.SHOW_DATASET_TABLE, dataId: dataId}

toggleFilterAnimation

Start and end filter animation

Parameters

Returns {type: ActionTypes.TOGGLE_FILTER_ANIMATION, idx: idx}

toggleLayerForMap

Toggle visibility of a layer in a split map

Parameters

Returns {type: ActionTypes.TOGGLE_LAYER_FOR_MAP, mapIndex: any, layerId: any}

updateAnimationTime

Reset animation

Parameters

Returns {type: ActionTypes.UPDATE_ANIMATION_TIME, value: value}

updateFilterAnimationSpeed

Change filter animation speed

Parameters

Returns {type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED, idx: idx, speed: speed}

updateLayerAnimationSpeed

update trip layer animation speed

Parameters

Returns {type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED, speed: speed}

updateLayerBlending

Update layer blending mode

Parameters

Returns {type: ActionTypes.UPDATE_LAYER_BLENDING, mode: mode}

updateVisData

Add new dataset to visState, with option to load a map config along with the datasets

Parameters

Returns {type: ActionTypes.UPDATE_VIS_DATA, datasets: datasets, options: options, config: config}

uiStateActions

Actions handled mostly by uiState reducer. They manage UI changes in tha app, such as open and close side panel, switch between tabs in the side panel, open and close modal dialog for exporting data / images etc. It also manges which settings are selected during image and map export

addNotification

Add a notification to be displayed. Existing notification is going to be updated in case of matching ids.

Parameters

cleanupExportImage

Delete cached export image

hideExportDropdown

Hide side panel header dropdown, activated by clicking the share link on top of the side panel

openDeleteModal

Toggle active map control panel

Parameters

removeNotification

Remove a notification

Parameters

setExportData

Whether to including data in map config, toggle between true or false

setExportDataType

Set data format for exporting data

Parameters

setExportFiltered

Whether to export filtered data, true or false

Parameters

setExportImageDataUri

Set exportImage.setExportImageDataUri to a dataUri

Parameters

setExportImageSetting

Set exportImage settings: ratio, resolution, legend

Parameters

setExportSelectedDataset

Set selected dataset for export

Parameters

setUserMapboxAccessToken

Whether we export a mapbox access token used to create a single map html file

Parameters

showExportDropdown

Hide and show side panel header dropdown, activated by clicking the share link on top of the side panel

Parameters

startExportingImage

Set exportImage.exporting to true

toggleMapControl

Toggle active map control panel

Parameters

toggleModal

Show and hide modal dialog

Parameters

toggleSidePanel

Toggle active side panel

Parameters

rootActions

Root actions managers adding and removing instances in root reducer. Under-the-hood, when a KeplerGl component is mounted or unmounted, it will automatically calls these actions to add itself to the root reducer. However, sometimes the data is ready before the component is registered in the reducer, in this case, you can manually call these actions or the corresponding updater to add it to the reducer.

deleteEntry

Delete an instance from keplerGlReducer. This action is called under-the-hood when a KeplerGl component is un-mounted to the dom. If mint is set to be true in the component prop, the instance state will be deleted from the root reducer. Otherwise, the root reducer will keep the instance state and later transfer it to a newly mounted component with the same id

Parameters

registerEntry

Add a new kepler.gl instance in keplerGlReducer. This action is called under-the-hood when a KeplerGl component is mounted to the dom. Note that if you dispatch actions such as adding data to a kepler.gl instance before the React component is mounted, the action will not be performed. Instance reducer can only handle actions when it is instantiated.

Parameters

  • payload Objectarrow-up-right

    • payload.id stringarrow-up-right *required The id of the instance

    • payload.mint booleanarrow-up-right Whether to use a fresh empty state, when mint: true it will always load a fresh state when the component is re-mounted. When mint: false it will register with existing instance state under the same id, when the component is unmounted then mounted again. Default: true

    • payload.mapboxApiAccessToken stringarrow-up-right mapboxApiAccessToken to be saved in map-style reducer.

    • payload.mapboxApiUrl stringarrow-up-right mapboxApiUrl to be saved in map-style reducer.

    • payload.mapStylesReplaceDefault Booleanarrow-up-right mapStylesReplaceDefault to be saved in map-style reducer.

renameEntry

Rename an instance in the root reducer, keep its entire state

Parameters

mapStateActions

Actions handled mostly by mapState reducer. They manage map viewport update, toggle between 2d and 3d map, toggle between single and split maps.

fitBounds

Fit map viewport to bounds

Parameters

Examples

togglePerspective

Toggle between 3d and 2d map.

Examples

toggleSplitMap

Toggle between single map or split maps

Parameters

Examples

updateMap

Update map viewport

Parameters

Examples

layerColorUIChange

Set the color palette ui for layer color

Parameters

setExportMapFormat

Set the export map format (html, json)

Parameters

Last updated

Was this helpful?