Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
Table of Contents
- forwardActions
- ActionTypes
- mapStyleActions
- main
- visStateActions
- addFilter
- addLayer
- addToDataset
- applyCPUFilter
- enlargeFilter
- interactionConfigChange
- layerConfigChange
- layerTextLabelChange
- layerTypeChange
- layerVisConfigChange
- layerVisualChannelConfigChange
- loadFiles
- loadFilesErr
- onLayerClick
- onLayerHover
- onMapClick
- onMouseMove
- removeDataset
- removeFromDataset
- removeFilter
- removeLayer
- reorderLayer
- setEditorMode
- setFilter
- setFilterPlot
- setMapInfo
- showDatasetTable
- toggleFilterAnimation
- toggleLayerForMap
- updateAnimationTime
- updateFilterAnimationSpeed
- updateLayerAnimationSpeed
- updateLayerBlending
- updateVisData
- uiStateActions
- addNotification
- cleanupExportImage
- hideExportDropdown
- openDeleteModal
- removeNotification
- setExportData
- setExportDataType
- setExportFiltered
- setExportImageDataUri
- setExportImageSetting
- setExportSelectedDataset
- setUserMapboxAccessToken
- showExportDropdown
- startExportingImage
- toggleMapControl
- toggleModal
- toggleSidePanel
- rootActions
- mapStateActions
- layerColorUIChange
- setExportMapFormat
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
// action and forward dispatcher
import {toggleSplitMap, forwardTo} from '@kepler.gl/actions';
import {connect} from 'react-redux';
const MapContainer = props => (
<div>
<button onClick={() => props.keplerGlDispatch(toggleSplitMap())}/>
</div>
)
const mapDispatchToProps = (dispatch, props) => ({
dispatch,
keplerGlDispatch: forwardTo(‘foo’, dispatch)
});
export default connect(
state => state,
mapDispatchToProps
)(MapContainer);
isForwardAction
Whether an action is a forward action
Parameters
actionObject the action object
Returns boolean boolean - whether the action is a forward action
unwrap
Unwrap an action
Parameters
actionObject the action object
Returns Object 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
{
type: "@@kepler.gl/LAYER_CONFIG_CHANGE",
payload: {
type: '@@kepler.gl/LAYER_CONFIG_CHANGE',
payload: {},
meta: {
// id of instance
_id_: id
// other meta
}
},
meta: {
_forward_: '@redux-forward/FORWARD',
_addr_: '@@KG_id'
}
};
Parameters
Examples
import {wrapTo, togglePerspective} from '@kepler.gl/actions';
// This action will only dispatch to the KeplerGl instance with `id: map_1`
this.props.dispatch(wrapTo('map_1', togglePerspective()));
// You can also create a curried action for each instance
const wrapToMap1 = wrapTo('map_1');
this.props.dispatch(wrapToMap1(togglePerspective()));
ActionTypes
Kepler.gl action types, can be listened by reducers to perform additional tasks whenever an action is called in kepler.gl
Type: Object
Examples
// store.js
import {handleActions} from 'redux-actions';
import {createStore, combineReducers, applyMiddleware} from 'redux';
import {taskMiddleware} from '@kepler.gl/tasks';
import keplerGlReducer from '@kepler.gl/reducers';
import {ActionTypes} from '@kepler.gl/actions';
const appReducer = handleActions(
{
// listen on kepler.gl map update action to store a copy of viewport in app state
[ActionTypes.UPDATE_MAP]: (state, action) => ({
...state,
viewport: action.payload
})
},
{}
);
const reducers = combineReducers({
app: appReducer,
keplerGl: keplerGlReducer
});
export default createStore(reducers, {}, applyMiddleware(taskMiddleware));
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}
- ActionTypes:
ActionTypes.ADD_CUSTOM_MAP_STYLE - Updaters:
mapStyleUpdaters.addCustomMapStyleUpdater
inputMapStyle
Input a custom map style object
- ActionTypes:
ActionTypes.INPUT_MAP_STYLE - Updaters:
mapStyleUpdaters.inputMapStyleUpdater
Parameters
inputStyleObjectinputStyle.urlstring style url e.g.'mapbox://styles/heshan/xxxxxyyyyzzz'inputStyle.idstring style url e.g.'custom_style_1'inputStyle.styleObject actual mapbox style jsoninputStyle.namestring style nameinputStyle.layerGroupsObject layer groups that can be used to set map layer visibilityinputStyle.iconObject icon image data url
mapStateObject mapState is optional
loadCustomMapStyle
Callback when a custom map style object is received
- ActionTypes:
ActionTypes.LOAD_CUSTOM_MAP_STYLE - Updaters:
mapStyleUpdaters.loadCustomMapStyleUpdater
Parameters
customMapStyleObject
loadMapStyleErr
Callback when load map style error
- ActionTypes:
ActionTypes.LOAD_MAP_STYLE_ERR - Updaters:
mapStyleUpdaters.loadMapStyleErrUpdater
Parameters
errorany
loadMapStyles
Callback when load map style success
- ActionTypes:
ActionTypes.LOAD_MAP_STYLES - Updaters:
mapStyleUpdaters.loadMapStylesUpdater
Parameters
newStylesObject a{[id]: style}mapping
mapConfigChange
Update visibleLayerGroups to change layer group visibility
- ActionTypes:
ActionTypes.MAP_CONFIG_CHANGE - Updaters:
mapStyleUpdaters.mapConfigChangeUpdater
Parameters
mapStyleObject 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
- ActionTypes:
ActionTypes.MAP_STYLE_CHANGE - Updaters:
mapStyleUpdaters.mapStyleChangeUpdater
Parameters
styleTypestring the style to change to
requestMapStyles
Request map style style object based on style.url.
- ActionTypes:
ActionTypes.REQUEST_MAP_STYLES - Updaters:
mapStyleUpdaters.requestMapStylesUpdater
Parameters
set3dBuildingColor
Set 3d building layer group color
- ActionTypes:
ActionTypes.SET_3D_BUILDING_COLOR - Updaters:
mapStyleUpdaters.set3dBuildingColorUpdater
Parameters
colorArray [r, g, b]
main
Main kepler.gl actions, these actions handles loading data and config into kepler.gl reducer. These actions are listened to 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 object.
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
- ActionTypes:
ActionTypes.ADD_DATA_TO_MAP - Updaters:
combinedUpdaters.addDataToMapUpdater
Parameters
dataObjectdata.datasets(Array<Object> | Object) *required datasets can be a dataset or an array of datasets Each dataset object needs to haveinfoanddataproperty.data.optionsObjectdata.options.centerMapbooleandefault: trueifcenterMapis set totruekepler.gl will place the map view within the data points boundaries.options.centerMapwill overrideconfig.mapStateif passed in.data.options.readOnlybooleandefault: falseifreadOnlyis set totruethe left setting panel will be hiddendata.options.keepExistingConfigboolean whether to keep exiting map data and associated layer filter interaction configdefault: false.
data.configObject this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
Examples
// app.js
import {addDataToMap} from '@kepler.gl/actions';
const sampleTripData = {
fields: [
{name: 'tpep_pickup_datetime', format: 'YYYY-M-D H:m:s', type: 'timestamp'},
{name: 'pickup_longitude', format: '', type: 'real'},
{name: 'pickup_latitude', format: '', type: 'real'}
],
rows: [
['2015-01-15 19:05:39 +00:00', -73.99389648, 40.75011063],
['2015-01-15 19:05:39 +00:00', -73.97642517, 40.73981094],
['2015-01-15 19:05:40 +00:00', -73.96870422, 40.75424576]
]
};
const sampleConfig = {
visState: {
filters: [
{
id: 'me',
dataId: 'test_trip_data',
name: 'tpep_pickup_datetime',
type: 'timeRange',
view: 'enlarged'
}
]
}
};
this.props.dispatch(
addDataToMap({
datasets: {
info: {
label: 'Sample Taxi Trips in New York City',
id: 'test_trip_data'
},
data: sampleTripData
},
options: {
centerMap: true,
readOnly: false,
keepExistingConfig: false
},
info: {
title: 'Taro and Blue',
description: 'This is my map'
},
config: sampleConfig
})
);
keplerGlInit
Initialize kepler.gl reducer. It is used to pass in mapboxApiAccessToken to mapStyle reducer.
- ActionTypes:
ActionTypes.INIT - Updaters:
mapStyleUpdaters.initMapStyleUpdater
Parameters
payloadObject
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.
- ActionTypes:
ActionTypes.RECEIVE_MAP_CONFIG - Updaters:
mapStateUpdaters.receiveMapConfigUpdater,mapStyleUpdaters.receiveMapConfigUpdater,visStateUpdaters.receiveMapConfigUpdater
Parameters
configObject *required The Config ObjectoptionsObject *optional The Option objectoptions.centerMapbooleandefault: trueifcenterMapis set totruekepler.gl will place the map view within the data points boundariesoptions.readOnlybooleandefault: falseifreadOnlyis set totruethe left setting panel will be hiddenoptions.keepExistingConfigboolean whether to keep exiting layer filter and interaction configdefault: false.
Examples
import {receiveMapConfig} from '@kepler.gl/actions';
import KeplerGlSchema from '@kepler.gl/schemas';
const parsedConfig = KeplerGlSchema.parseSavedConfig(config);
this.props.dispatch(receiveMapConfig(parsedConfig));
resetMapConfig
Reset all sub-reducers to its initial state. This can be used to clear out all configuration in the reducer.
- ActionTypes:
ActionTypes.RESET_MAP_CONFIG - Updaters:
mapStateUpdaters.resetMapConfigUpdater,mapStyleUpdaters.resetMapConfigMapStyleUpdater,mapStyleUpdaters.resetMapConfigMapStyleUpdater,visStateUpdaters.resetMapConfigUpdater
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
- ActionTypes:
ActionTypes.ADD_FILTER - Updaters:
visStateUpdaters.addFilterUpdater
Parameters
dataIdstring datasetidthis new filter is associated with
Returns {type: ActionTypes.ADD_FILTER, dataId: dataId}
addLayer
Add a new layer
- ActionTypes:
ActionTypes.ADD_LAYER - Updaters:
visStateUpdaters.addLayerUpdater
Parameters
propsObject new layer props
Returns {type: ActionTypes.ADD_LAYER, props: props}
addToDataset
Append or upsert rows on an existing in-memory row or Arrow dataset without addDataToMap. Keeps layer identity and style. Pass options.upsertBy to replace rows that share that key and append the rest.
DuckDB tables (no INSERT yet) warn and leave the table unchanged. Arrow tables support primitive columns; nested, binary, and geoarrow columns are rejected. Encoding failures and dictionary index overflow reject the whole edit batch. Use addDataToMap with keepExistingConfig for a full replace.
- ActionTypes:
ActionTypes.ADD_TO_DATASET - Updaters:
visStateUpdaters.addToDatasetUpdater
Parameters
dataIdstring dataset idrowsone row or an array of rows (column-ordered arrays, or objects keyed by field name)optionsObject (optional){upsertBy: string}unique key field
Returns {type: ActionTypes.ADD_TO_DATASET, dataId, rows, options}
applyCPUFilter
Trigger CPU filter of selected dataset
- ActionTypes:
ActionTypes.APPLY_CPU_FILTER - Updaters:
visStateUpdaters.applyCPUFilterUpdater
Parameters
Returns {type: ActionTypes.APPLY_CPU_FILTER, dataId: string}
enlargeFilter
Show larger time filter at bottom for time playback (apply to time filter only)
- ActionTypes:
ActionTypes.ENLARGE_FILTER - Updaters:
visStateUpdaters.enlargeFilterUpdater
Parameters
idxNumber index of filter to enlarge
Returns {type: ActionTypes.ENLARGE_FILTER, idx: idx}
interactionConfigChange
Update interactionConfig
- ActionTypes:
ActionTypes.INTERACTION_CONFIG_CHANGE - Updaters:
visStateUpdaters.interactionConfigChangeUpdater
Parameters
configObject new config as key value map:{tooltip: {enabled: true}}
Returns {type: ActionTypes.INTERACTION_CONFIG_CHANGE, config: config}
layerConfigChange
Update layer base config: dataId, label, column, isVisible
- ActionTypes:
ActionTypes.LAYER_CONFIG_CHANGE - Updaters:
visStateUpdaters.layerConfigChangeUpdater
Parameters
Returns {type: ActionTypes.LAYER_CONFIG_CHANGE, oldLayer: oldLayer, newConfig: newConfig}
layerTextLabelChange
Update layer text label
- ActionTypes:
ActionTypes.LAYER_TEXT_LABEL_CHANGE - Updaters:
visStateUpdaters.layerTextLabelChangeUpdater
Parameters
oldLayerObject layer to be updatedidxNumber -idxof text label to be updatedpropstringpropof text label, e,g,anchor,alignment,color,size,fieldvalueany new value
layerTypeChange
Update layer type. Previous layer config will be copied if applicable.
- ActionTypes:
ActionTypes.LAYER_TYPE_CHANGE - Updaters:
visStateUpdaters.layerTypeChangeUpdater
Parameters
Returns {type: ActionTypes.LAYER_TYPE_CHANGE, oldLayer: oldLayer, newType: newType}
layerVisConfigChange
Update layer visConfig
- ActionTypes:
ActionTypes.LAYER_VIS_CONFIG_CHANGE - Updaters:
visStateUpdaters.layerVisConfigChangeUpdater
Parameters
oldLayerObject layer to be updatednewVisConfigObject new visConfig as a key value map: e.g.{opacity: 0.8}
Returns {type: ActionTypes.LAYER_VIS_CONFIG_CHANGE, oldLayer: oldLayer, newVisConfig: newVisConfig}
layerVisualChannelConfigChange
Update layer visual channel
- ActionTypes:
ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE - Updaters:
visStateUpdaters.layerVisualChannelChangeUpdater
Parameters
oldLayerObject layer to be updatednewConfigObject new visual channel configchannelstring channel to be updated
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
- ActionTypes:
ActionTypes.LOAD_FILES - Updaters:
uiStateUpdaters.loadFilesUpdater,visStateUpdaters.loadFilesUpdater
Parameters
Returns {type: ActionTypes.LOAD_FILES, files: any}
loadFilesErr
Trigger loading file error
- ActionTypes:
ActionTypes.LOAD_FILES_ERR - Updaters:
uiStateUpdaters.loadFilesErrUpdater,visStateUpdaters.loadFilesErrUpdater
Parameters
errorany
Returns {type: ActionTypes.LOAD_FILES_ERR, error: Object}
onLayerClick
Trigger layer click event with clicked object
- ActionTypes:
ActionTypes.LAYER_CLICK - Updaters:
visStateUpdaters.layerClickUpdater
Parameters
infoObject Object clicked, returned by deck.gl
Returns {type: ActionTypes.LAYER_CLICK, info: info}
onLayerHover
Trigger layer hover event with hovered object
- ActionTypes:
ActionTypes.LAYER_HOVER - Updaters:
visStateUpdaters.layerHoverUpdater
Parameters
infoObject Object hovered, returned by deck.gl
Returns {type: ActionTypes.LAYER_HOVER, info: info}
onMapClick
Trigger map click event, unselect clicked object
- ActionTypes:
ActionTypes.MAP_CLICK - Updaters:
visStateUpdaters.mapClickUpdater
Returns {type: ActionTypes.MAP_CLICK}
onMouseMove
Trigger map mouse move event, payload would be React-map-gl MapLayerMouseEvent https://visgl.github.io/react-map-gl/docs/api-reference/types#maplayermouseevent
- ActionTypes:
ActionTypes.MOUSE_MOVE - Updaters:
visStateUpdaters.mouseMoveUpdater
Parameters
evtObject MapLayerMouseEvent
Returns {type: ActionTypes.MOUSE_MOVE}
removeDataset
Remove a dataset and all layers, filters, tooltip configs that based on it
- ActionTypes:
ActionTypes.REMOVE_DATASET - Updaters:
visStateUpdaters.removeDatasetUpdater
Parameters
keystring dataset id
Returns {type: ActionTypes.REMOVE_DATASET, key: key}
removeFromDataset
Delete rows from an existing in-memory row or Arrow dataset without restyling layers. The second argument is either row indexes or {field, values} to match a column (for example an id).
DuckDB tables warn and leave the table unchanged. Arrow tables compact the retained rows while preserving nested values, exact timestamp storage, and shared dictionaries.
- ActionTypes:
ActionTypes.REMOVE_FROM_DATASET - Updaters:
visStateUpdaters.removeFromDatasetUpdater
Parameters
dataIdstring dataset idrowIndexesOrMatcherone index, an array of indexes, or{field, values}
Returns {type: ActionTypes.REMOVE_FROM_DATASET, dataId, rowIndexes?, byField?}
removeFilter
Remove a filter from visState.filters, once a filter is removed, data will be re-filtered and layer will be updated
- ActionTypes:
ActionTypes.REMOVE_FILTER - Updaters:
visStateUpdaters.removeFilterUpdater
Parameters
idxNumber idx of filter to be removed
Returns {type: ActionTypes.REMOVE_FILTER, idx: idx}
removeLayer
Remove a layer
- ActionTypes:
ActionTypes.REMOVE_LAYER - Updaters:
visStateUpdaters.removeLayerUpdater
Parameters
idxNumber idx of layer to be removed
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
- ActionTypes:
ActionTypes.REORDER_LAYER - Updaters:
visStateUpdaters.reorderLayerUpdater
Parameters
Examples
// bring `layers[1]` below `layers[0]`, the sequence layers will be rendered is `1`, `0`, `2`, `3`.
// `1` will be at the bottom, `3` will be at the top.
this.props.dispatch(reorderLayer([1, 0, 2, 3]));
Returns {type: ActionTypes.REORDER_LAYER, order: order}
setEditorMode
Set the Draw on Map editor mode
- ActionTypes:
ActionTypes.SET_EDITOR_MODE - Updaters:
visStateUpdaters.setEditorModeUpdater
Parameters
modestring one ofEDITOR_MODES:EDIT,DRAW_POINT,DRAW_LINESTRING,DRAW_POLYGON,DRAW_RECTANGLE,DRAW_CIRCLE
Examples
import {setEditorMode} from '@kepler.gl/actions';
import {EDITOR_MODES} from '@kepler.gl/constants';
this.props.dispatch(setEditorMode(EDITOR_MODES.DRAW_LINESTRING));
setFilter
Update filter property
- ActionTypes:
ActionTypes.SET_FILTER - Updaters:
visStateUpdaters.setFilterUpdater
Parameters
idxNumber -idxof filter to be updatedpropstringpropof filter, e,g,dataId,name,valuevalueany new valuevalueIndexNumber array properties like dataset require index in order to improve performance
Returns {type: ActionTypes.SET_FILTER, idx: idx, prop: prop, value: value}
setFilterPlot
Set the property of a filter plot
- ActionTypes:
ActionTypes.SET_FILTER_PLOT - Updaters:
visStateUpdaters.setFilterPlotUpdater
Parameters
Returns {type: ActionTypes.SET_FILTER_PLOT, idx: any, newProp: any}
setMapInfo
Set map info such as title and description
- ActionTypes:
ActionTypes.SET_MAP_INFO - Updaters:
visStateUpdaters.setMapInfoUpdater
Parameters
infoObject map info object, e.g.{title: 'My Map', description: 'My map description'}
Returns {type: ActionTypes.SET_MAP_INFO, info: info}
showDatasetTable
Display dataset table in a modal
- ActionTypes:
ActionTypes.SHOW_DATASET_TABLE - Updaters:
visStateUpdaters.showDatasetTableUpdater
Parameters
dataIdstring dataset id to show in table
Returns {type: ActionTypes.SHOW_DATASET_TABLE, dataId: dataId}
toggleFilterAnimation
Start and end filter animation
- ActionTypes:
ActionTypes.TOGGLE_FILTER_ANIMATION - Updaters:
visStateUpdaters.toggleFilterAnimationUpdater
Parameters
idxNumber idx of filter
Returns {type: ActionTypes.TOGGLE_FILTER_ANIMATION, idx: idx}
toggleLayerForMap
Toggle visibility of a layer in a split map
- ActionTypes:
ActionTypes.TOGGLE_LAYER_FOR_MAP - Updaters:
visStateUpdaters.toggleLayerForMapUpdater
Parameters
Returns {type: ActionTypes.TOGGLE_LAYER_FOR_MAP, mapIndex: any, layerId: any}
updateAnimationTime
Reset animation
- ActionTypes:
ActionTypes.UPDATE_ANIMATION_TIME - Updaters:
visStateUpdaters.updateAnimationTimeUpdater
Parameters
valueNumber Current value of the slider
Returns {type: ActionTypes.UPDATE_ANIMATION_TIME, value: value}
updateFilterAnimationSpeed
Change filter animation speed
- ActionTypes:
ActionTypes.UPDATE_FILTER_ANIMATION_SPEED - Updaters:
visStateUpdaters.updateFilterAnimationSpeedUpdater
Parameters
Returns {type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED, idx: idx, speed: speed}
updateLayerAnimationSpeed
update trip layer animation speed
- ActionTypes:
ActionTypes.UPDATE_LAYER_ANIMATION_SPEED - Updaters:
visStateUpdaters.updateLayerAnimationSpeedUpdater
Parameters
speedNumberspeedto change it to.speedis a multiplier
Returns {type: ActionTypes.UPDATE_LAYER_ANIMATION_SPEED, speed: speed}
updateLayerBlending
Update layer blending mode
- ActionTypes:
ActionTypes.UPDATE_LAYER_BLENDING - Updaters:
visStateUpdaters.updateLayerBlendingUpdater
Parameters
modestring one ofadditive,normalandsubtractive
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
- ActionTypes:
ActionTypes.UPDATE_VIS_DATA - Updaters:
visStateUpdaters.updateVisDataUpdater
Parameters
datasets(Array<Object> | Object) *required datasets can be a dataset or an array of datasets Each dataset object needs to haveinfoanddataproperty.optionsObjectconfigObject this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
Returns {type: ActionTypes.UPDATE_VIS_DATA, datasets: datasets, options: options, config: config}
uiStateActions
Actions handled mostly by uiState reducer.
They manage UI changes in the 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 manages 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.
- ActionTypes:
ActionTypes.ADD_NOTIFICATION - Updaters:
uiStateUpdaters.addNotificationUpdater
Parameters
notificationObject Thenotificationobject to be added
cleanupExportImage
Delete cached export image
- ActionTypes:
ActionTypes.CLEANUP_EXPORT_IMAGE - Updaters:
uiStateUpdaters.cleanupExportImage
hideExportDropdown
Hide side panel header dropdown, activated by clicking the share link on top of the side panel
- ActionTypes:
ActionTypes.HIDE_EXPORT_DROPDOWN - Updaters:
uiStateUpdaters.hideExportDropdownUpdater
openDeleteModal
Toggle active map control panel
- ActionTypes:
ActionTypes.OPEN_DELETE_MODAL - Updaters:
uiStateUpdaters.openDeleteModalUpdater
Parameters
datasetIdstringidof the dataset to be deleted
removeNotification
Remove a notification
- ActionTypes:
ActionTypes.REMOVE_NOTIFICATION - Updaters:
uiStateUpdaters.removeNotificationUpdater
Parameters
idstringidof the notification to be removed
setExportData
Whether to including data in map config, toggle between true or false
- ActionTypes:
ActionTypes.SET_EXPORT_DATA - Updaters:
uiStateUpdaters.setExportDataUpdater
setExportDataType
Set data format for exporting data
- ActionTypes:
ActionTypes.SET_EXPORT_DATA_TYPE - Updaters:
uiStateUpdaters.setExportDataTypeUpdater
Parameters
dataTypestring one of'text/csv'
setExportFiltered
Whether to export filtered data, true or false
- ActionTypes:
ActionTypes.SET_EXPORT_FILTERED - Updaters:
uiStateUpdaters.setExportFilteredUpdater
Parameters
payloadboolean settrueto only export filtered data
setExportImageDataUri
Set exportImage.setExportImageDataUri to a dataUri
- ActionTypes:
ActionTypes.SET_EXPORT_IMAGE_DATA_URI - Updaters:
uiStateUpdaters.setExportImageDataUri
Parameters
dataUristring export image data uri
setExportImageSetting
Set exportImage settings: ratio, resolution, legend
- ActionTypes:
ActionTypes.SET_EXPORT_IMAGE_SETTING - Updaters:
uiStateUpdaters.setExportImageSetting
Parameters
newSettingObject {ratio: '1x'}
setExportSelectedDataset
Set selected dataset for export
- ActionTypes:
ActionTypes.SET_EXPORT_SELECTED_DATASET - Updaters:
uiStateUpdaters.setExportSelectedDatasetUpdater
Parameters
datasetIdstring dataset id
setUserMapboxAccessToken
Whether we export a mapbox access token used to create a single map html file
- ActionTypes:
ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN - Updaters:
uiStateUpdaters.setUserMapboxAccessTokenUpdater
Parameters
payloadstring mapbox access token
showExportDropdown
Hide and show side panel header dropdown, activated by clicking the share link on top of the side panel
- ActionTypes:
ActionTypes.SHOW_EXPORT_DROPDOWN - Updaters:
uiStateUpdaters.showExportDropdownUpdater
Parameters
idstring id of the dropdown
startExportingImage
Set exportImage.exporting to true
- ActionTypes:
ActionTypes.START_EXPORTING_IMAGE - Updaters:
uiStateUpdaters.startExportingImage
toggleMapControl
Toggle active map control panel
- ActionTypes:
ActionTypes.TOGGLE_MAP_CONTROL - Updaters:
uiStateUpdaters.toggleMapControlUpdater
Parameters
panelIdstring map control panel id, one of the keys of:DEFAULT_MAP_CONTROLS
toggleModal
Show and hide modal dialog
- ActionTypes:
ActionTypes.TOGGLE_MODAL - Updaters:
uiStateUpdaters.toggleModalUpdater
Parameters
id(string | null) id of modal to be shown, null to hide modals. One of:-DATA_TABLE_ID
toggleSidePanel
Toggle active side panel
- ActionTypes:
ActionTypes.TOGGLE_SIDE_PANEL - Updaters:
uiStateUpdaters.toggleSidePanelUpdater
Parameters
idstring id of side panel to be shown, one oflayer,filter,interaction,map
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
- ActionTypes:
ActionTypes.DELETE_ENTRY - Updaters:
Parameters
idstring the id of the instance to be deleted
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.
- ActionTypes:
ActionTypes.REGISTER_ENTRY - Updaters:
Parameters
payloadObjectpayload.idstring *required The id of the instancepayload.mintboolean Whether to use a fresh empty state, whenmint: trueit will always load a fresh state when the component is re-mounted. Whenmint: falseit will register with existing instance state under the sameid, when the component is unmounted then mounted again. Default:truepayload.mapboxApiAccessTokenstring mapboxApiAccessToken to be saved inmap-stylereducer.payload.mapboxApiUrlstring mapboxApiUrl to be saved inmap-stylereducer.payload.mapStylesReplaceDefaultBoolean mapStylesReplaceDefault to be saved inmap-stylereducer.
renameEntry
Rename an instance in the root reducer, keep its entire state
- ActionTypes:
ActionTypes.RENAME_ENTRY - Updaters:
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
- ActionTypes:
ActionTypes.FIT_BOUNDS - Updaters:
mapStateUpdaters.fitBoundsUpdater
Parameters
Examples
import {fitBounds} from '@kepler.gl/actions';
this.props.dispatch(fitBounds([-122.23, 37.127, -122.11, 37.456]));
togglePerspective
Toggle between 3d and 2d map.
- ActionTypes:
ActionTypes.TOGGLE_PERSPECTIVE - Updaters:
mapStateUpdaters.togglePerspectiveUpdater
Examples
import {togglePerspective} from '@kepler.gl/actions';
this.props.dispatch(togglePerspective());
toggleSplitMap
Toggle between single map or split maps
- ActionTypes:
ActionTypes.TOGGLE_SPLIT_MAP - Updaters:
mapStateUpdaters.toggleSplitMapUpdater,uiStateUpdaters.toggleSplitMapUpdater,visStateUpdaters.toggleSplitMapUpdater
Parameters
indexNumber? index is provided, close split map at index
Examples
import {toggleSplitMap} from '@kepler.gl/actions';
this.props.dispatch(toggleSplitMap());
updateMap
Update map viewport
- ActionTypes:
ActionTypes.UPDATE_MAP - Updaters:
mapStateUpdaters.updateMapUpdater
Parameters
viewportObject viewport object container one or any of these propertieswidth,height,latitudelongitude,zoom,pitch,bearing,dragRotateviewport.widthNumber? Width of viewportviewport.heightNumber? Height of viewportviewport.zoomNumber? Zoom of viewportviewport.pitchNumber? Camera angle in degrees (0 is straight down)viewport.bearingNumber? Map rotation in degrees (0 means north is up)viewport.latitudeNumber? Latitude center of viewport on map in mercator projectionviewport.longitudeNumber? Longitude Center of viewport on map in mercator projectionviewport.dragRotateboolean? Whether to enable drag and rotate map into perspective viewport
Examples
import {updateMap} from '@kepler.gl/actions';
this.props.dispatch(
updateMap({latitude: 37.75043, longitude: -122.34679, width: 800, height: 1200})
);
layerColorUIChange
Set the color palette ui for layer color
- ActionTypes:
ActionTypes.LAYER_COLOR_UI_CHANGE - Updaters:
visStateUpdaters.layerColorUIChangeUpdater
Parameters
setExportMapFormat
Set the export map format (html, json)
- ActionTypes:
ActionTypes.SET_EXPORT_MAP_FORMAT - Updaters:
uiStateUpdaters.setExportMapFormatUpdater
Parameters
payloadstring map format