Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] add keepExistingConfig option to addDataToMap (#619)

Shan He1d503f3c5a83
diff --git a/README.md b/README.md
index 2c8417484..978047b72 100644
--- a/README.md
+++ b/README.md
@@ -499,10 +499,11 @@ To interact with a kepler.gl instance and add new data to it, you can dispatch *
- `datasets.data.fields.name` **[string][42]** **\*required** Name of the field,
- `datasets.data.rows` **[Array][41]<[Array][41]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
- `options` **[Object][40]**
- - `options.centerMap` **[boolean][43]** `default: true` if `centerMap` is set to `true` kepler.gl will
- place the map view within the data points boundaries
+ - `options.centerMap` **[boolean][43]** `default: true` if `centerMap` is set to `true` kepler.gl will place the map view within the data points boundaries
- `options.readOnly` **[boolean][43]** `default: false` if `readOnly` is set to `true`
the left setting panel will be hidden
+ - `options.keepExistingConfig` **[boolean][43]** `default: false` whether to keep exiting map config, including layers, filters and splitMaps.
+
- `config` **[Object][40]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
Kepler.gl provides an easy API `KeplerGlSchema.getConfigToSave` to generate a json blob of the current kepler instance configuration.
diff --git a/docs/api-reference/actions/actions.md b/docs/api-reference/actions/actions.md
index 3e1ebeb78..e27e887d2 100644
--- a/docs/api-reference/actions/actions.md
+++ b/docs/api-reference/actions/actions.md
@@ -17,68 +17,70 @@
- [mapConfigChange][24]
- [mapStyleChange][26]
- [requestMapStyles][28]
-- [main][30]
- - [addDataToMap][31]
- - [keplerGlInit][34]
- - [receiveMapConfig][36]
- - [resetMapConfig][39]
-- [visStateActions][40]
- - [addFilter][41]
- - [addLayer][43]
- - [enlargeFilter][45]
- - [interactionConfigChange][47]
- - [layerConfigChange][49]
- - [layerTypeChange][51]
- - [layerVisConfigChange][53]
- - [layerVisualChannelConfigChange][55]
- - [loadFiles][57]
- - [loadFilesErr][59]
- - [onLayerClick][61]
- - [onLayerHover][63]
- - [onMapClick][65]
- - [removeDataset][66]
- - [removeFilter][68]
- - [removeLayer][70]
- - [reorderLayer][72]
- - [setFilter][75]
- - [setFilterPlot][77]
- - [setVisibleLayersForMap][79]
- - [showDatasetTable][81]
- - [toggleAnimation][83]
- - [toggleLayerForMap][85]
- - [updateAnimationSpeed][87]
- - [updateLayerBlending][89]
- - [updateVisData][91]
-- [uiStateActions][93]
- - [addNotification][94]
- - [cleanupExportImage][96]
- - [hideExportDropdown][97]
- - [openDeleteModal][98]
- - [removeNotification][100]
- - [setExportData][102]
- - [setExportDataType][103]
- - [setExportFiltered][105]
- - [setExportImageDataUri][107]
- - [setExportSelectedDataset][109]
- - [setRatio][111]
- - [setResolution][113]
- - [setUserMapboxAccessToken][115]
- - [showExportDropdown][117]
- - [startExportingImage][119]
- - [toggleLegend][120]
- - [toggleMapControl][121]
- - [toggleModal][123]
- - [toggleSidePanel][125]
-- [rootActions][127]
- - [deleteEntry][128]
- - [registerEntry][130]
- - [renameEntry][132]
-- [mapStateActions][134]
- - [fitBounds][135]
- - [togglePerspective][138]
- - [toggleSplitMap][140]
- - [updateMap][143]
-- [setExportMapFormat][146]
+ - [set3dBuildingColor][30]
+- [main][32]
+ - [addDataToMap][33]
+ - [keplerGlInit][36]
+ - [receiveMapConfig][38]
+ - [resetMapConfig][41]
+- [visStateActions][42]
+ - [addFilter][43]
+ - [addLayer][45]
+ - [enlargeFilter][47]
+ - [interactionConfigChange][49]
+ - [layerConfigChange][51]
+ - [layerTextLabelChange][53]
+ - [layerTypeChange][55]
+ - [layerVisConfigChange][57]
+ - [layerVisualChannelConfigChange][59]
+ - [loadFiles][61]
+ - [loadFilesErr][63]
+ - [onLayerClick][65]
+ - [onLayerHover][67]
+ - [onMapClick][69]
+ - [onMouseMove][70]
+ - [removeDataset][72]
+ - [removeFilter][74]
+ - [removeLayer][76]
+ - [reorderLayer][78]
+ - [setFilter][81]
+ - [setFilterPlot][83]
+ - [showDatasetTable][85]
+ - [toggleAnimation][87]
+ - [toggleLayerForMap][89]
+ - [updateAnimationSpeed][91]
+ - [updateLayerBlending][93]
+ - [updateVisData][95]
+- [uiStateActions][97]
+ - [addNotification][98]
+ - [cleanupExportImage][100]
+ - [hideExportDropdown][101]
+ - [openDeleteModal][102]
+ - [removeNotification][104]
+ - [setExportData][106]
+ - [setExportDataType][107]
+ - [setExportFiltered][109]
+ - [setExportImageDataUri][111]
+ - [setExportSelectedDataset][113]
+ - [setRatio][115]
+ - [setResolution][117]
+ - [setUserMapboxAccessToken][119]
+ - [showExportDropdown][121]
+ - [startExportingImage][123]
+ - [toggleLegend][124]
+ - [toggleMapControl][125]
+ - [toggleModal][127]
+ - [toggleSidePanel][129]
+- [rootActions][131]
+ - [deleteEntry][132]
+ - [registerEntry][134]
+ - [renameEntry][136]
+- [mapStateActions][138]
+ - [fitBounds][139]
+ - [togglePerspective][142]
+ - [toggleSplitMap][144]
+ - [updateMap][147]
+- [setExportMapFormat][150]
## forwardActions
@@ -90,8 +92,8 @@ Returns an action dispatcher that wraps and forwards the actions to a specific i
**Parameters**
-- `id` **[string][148]** instance id
-- `dispatch` **[Function][149]** action dispatcher
+- `id` **[string][152]** instance id
+- `dispatch` **[Function][153]** action dispatcher
**Examples**
@@ -123,9 +125,9 @@ Whether an action is a forward action
**Parameters**
-- `action` **[Object][150]** the action object
+- `action` **[Object][154]** the action object
-Returns **[boolean][151]** boolean - whether the action is a forward action
+Returns **[boolean][155]** boolean - whether the action is a forward action
### unwrap
@@ -133,9 +135,9 @@ Unwrap an action
**Parameters**
-- `action` **[Object][150]** the action object
+- `action` **[Object][154]** the action object
-Returns **[Object][150]** unwrapped action
+Returns **[Object][154]** unwrapped action
### wrapTo
@@ -168,8 +170,8 @@ A forward action looks like this
**Parameters**
-- `id` **[string][148]** The id to forward to
-- `action` **[Object][150]** the action object {type: string, payload: \*}
+- `id` **[string][152]** The id to forward to
+- `action` **[Object][154]** the action object {type: string, payload: \*}
**Examples**
@@ -188,7 +190,7 @@ this.props.dispatch(wrapToMap1(togglePerspective()));
Kepler.gl action types, can be listened by reducers to perform additional tasks whenever an action is called in kepler.gl
-Type: [Object][150]
+Type: [Object][154]
**Examples**
@@ -231,37 +233,37 @@ It should not be called from outside kepler.gl without a valid `inputStyle` in t
param {void}
- **ActionTypes**: [`ActionTypes.ADD_CUSTOM_MAP_STYLE`][12]
-- **Updaters**: [`mapStyleUpdaters.addCustomMapStyleUpdater`][152]
+- **Updaters**: [`mapStyleUpdaters.addCustomMapStyleUpdater`][156]
### inputMapStyle
Input a custom map style object
- **ActionTypes**: [`ActionTypes.INPUT_MAP_STYLE`][12]
-- **Updaters**: [`mapStyleUpdaters.inputMapStyleUpdater`][153]
+- **Updaters**: [`mapStyleUpdaters.inputMapStyleUpdater`][157]
**Parameters**
-- `inputStyle` **[Object][150]**
- - `inputStyle.url` **[string][148]** style url e.g. `'mapbox://styles/heshan/xxxxxyyyyzzz'`
- - `inputStyle.id` **[string][148]** style url e.g. `'custom_style_1'`
- - `inputStyle.style` **[Object][150]** actual mapbox style json
- - `inputStyle.name` **[string][148]** style name
- - `inputStyle.layerGroups` **[Object][150]** layer groups that can be used to set map layer visibility
- - `inputStyle.icon` **[Object][150]** icon image data url
+- `inputStyle` **[Object][154]**
+ - `inputStyle.url` **[string][152]** style url e.g. `'mapbox://styles/heshan/xxxxxyyyyzzz'`
+ - `inputStyle.id` **[string][152]** style url e.g. `'custom_style_1'`
+ - `inputStyle.style` **[Object][154]** actual mapbox style json
+ - `inputStyle.name` **[string][152]** style name
+ - `inputStyle.layerGroups` **[Object][154]** layer groups that can be used to set map layer visibility
+ - `inputStyle.icon` **[Object][154]** icon image data url
### loadCustomMapStyle
Callback when a custom map style object is received
- **ActionTypes**: [`ActionTypes.LOAD_CUSTOM_MAP_STYLE`][12]
-- **Updaters**: [`mapStyleUpdaters.loadCustomMapStyleUpdater`][154]
+- **Updaters**: [`mapStyleUpdaters.loadCustomMapStyleUpdater`][158]
**Parameters**
-- `customMapStyle` **[Object][150]**
- - `customMapStyle.icon` **[string][148]**
- - `customMapStyle.style` **[Object][150]**
+- `customMapStyle` **[Object][154]**
+ - `customMapStyle.icon` **[string][152]**
+ - `customMapStyle.style` **[Object][154]**
- `customMapStyle.error` **any**
### loadMapStyleErr
@@ -269,7 +271,7 @@ Callback when a custom map style object is received
Callback when load map style error
- **ActionTypes**: [`ActionTypes.LOAD_MAP_STYLE_ERR`][12]
-- **Updaters**: [`mapStyleUpdaters.loadMapStyleErrUpdater`][155]
+- **Updaters**: [`mapStyleUpdaters.loadMapStyleErrUpdater`][159]
**Parameters**
@@ -280,44 +282,55 @@ Callback when load map style error
Callback when load map style success
- **ActionTypes**: [`ActionTypes.LOAD_MAP_STYLES`][12]
-- **Updaters**: [`mapStyleUpdaters.loadMapStylesUpdater`][156]
+- **Updaters**: [`mapStyleUpdaters.loadMapStylesUpdater`][160]
**Parameters**
-- `newStyles` **[Object][150]** a `{[id]: style}` mapping
+- `newStyles` **[Object][154]** a `{[id]: style}` mapping
### mapConfigChange
Update `visibleLayerGroups`to change layer group visibility
- **ActionTypes**: [`ActionTypes.MAP_CONFIG_CHANGE`][12]
-- **Updaters**: [`mapStyleUpdaters.mapConfigChangeUpdater`][157]
+- **Updaters**: [`mapStyleUpdaters.mapConfigChangeUpdater`][161]
**Parameters**
-- `mapStyle` **[Object][150]** new config `{visibleLayerGroups: {label: false, road: true, background: true}}`
+- `mapStyle` **[Object][154]** 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`][12]
-- **Updaters**: [`mapStyleUpdaters.mapStyleChangeUpdater`][158]
+- **Updaters**: [`mapStyleUpdaters.mapStyleChangeUpdater`][162]
**Parameters**
-- `styleType` **[string][148]** the style to change to
+- `styleType` **[string][152]** the style to change to
### requestMapStyles
Request map style style object based on style.url.
- **ActionTypes**: [`ActionTypes.REQUEST_MAP_STYLES`][12]
-- **Updaters**: [`mapStyleUpdaters.requestMapStylesUpdater`][159]
+- **Updaters**: [`mapStyleUpdaters.requestMapStylesUpdater`][163]
**Parameters**
-- `mapStyles` **[Array][160]<[Object][150]>**
+- `mapStyles` **[Array][164]<[Object][154]>**
+
+### set3dBuildingColor
+
+Set 3d building layer group color
+
+- **ActionTypes**: [`ActionTypes.SET_3D_BUILDING_COLOR`][12]
+- **Updaters**: [`mapStyleUpdaters.set3dBuildingColorUpdater`][165]
+
+**Parameters**
+
+- `color` **[Array][164]** [r, g, b]
## main
@@ -336,26 +349,27 @@ Kepler.gl uses `dataId` in the config to match with loaded dataset. If you pass
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`][12]
-- **Updaters**: [`combinedUpdaters.addDataToMapUpdater`][161]
+- **Updaters**: [`combinedUpdaters.addDataToMapUpdater`][166]
**Parameters**
-- `data` **[Object][150]**
- - `data.datasets` **([Array][160]<[Object][150]> | [Object][150])** **\*required** datasets can be a dataset or an array of datasets
+- `data` **[Object][154]**
+ - `data.datasets` **([Array][164]<[Object][154]> | [Object][154])** **\*required** datasets can be a dataset or an array of datasets
Each dataset object needs to have `info` and `data` property.
- - `data.datasets.info` **[Object][150]** \-info of a dataset
- - `data.datasets.info.id` **[string][148]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- - `data.datasets.info.label` **[string][148]** A display name of this dataset
- - `data.datasets.data` **[Object][150]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
- - `data.datasets.data.fields` **[Array][160]<[Object][150]>** **\*required** Array of fields,
- - `data.datasets.data.fields.name` **[string][148]** **\*required** Name of the field,
- - `data.datasets.data.rows` **[Array][160]<[Array][160]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
- - `data.options` **[Object][150]**
- - `data.options.centerMap` **[boolean][151]** `default: true` if `centerMap` is set to `true` kepler.gl will
- place the map view within the data points boundaries
- - `data.options.readOnly` **[boolean][151]** `default: false` if `readOnly` is set to `true`
+ - `data.datasets.info` **[Object][154]** \-info of a dataset
+ - `data.datasets.info.id` **[string][152]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ - `data.datasets.info.label` **[string][152]** A display name of this dataset
+ - `data.datasets.data` **[Object][154]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ - `data.datasets.data.fields` **[Array][164]<[Object][154]>** **\*required** Array of fields,
+ - `data.datasets.data.fields.name` **[string][152]** **\*required** Name of the field,
+ - `data.datasets.data.rows` **[Array][164]<[Array][164]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
+ - `data.options` **[Object][154]**
+ - `data.options.centerMap` **[boolean][155]** `default: true` if `centerMap` is set to `true` kepler.gl will
+ place the map view within the data points boundaries. `options.centerMap` will override `config.mapState` if passed in.
+ - `data.options.readOnly` **[boolean][155]** `default: false` if `readOnly` is set to `true`
the left setting panel will be hidden
- - `data.config` **[Object][150]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
+ - `data.options.keepExistingConfig` **[boolean][155]** whether to keep exiting map data and associated layer filter interaction config `default: false`.
+ - `data.config` **[Object][154]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
**Examples**
@@ -401,7 +415,8 @@ this.props.dispatch(
},
option: {
centerMap: true,
- readOnly: false
+ readOnly: false,
+ keepExistingConfig: false
},
config: sampleConfig
})
@@ -413,12 +428,14 @@ this.props.dispatch(
Initialize kepler.gl reducer. It is used to pass in `mapboxApiAccessToken` to `mapStyle` reducer.
- **ActionTypes**: [`ActionTypes.INIT`][12]
-- **Updaters**: [`mapStyleUpdaters.initMapStyleUpdater`][162]
+- **Updaters**: [`mapStyleUpdaters.initMapStyleUpdater`][167]
**Parameters**
-- `payload` **[Object][150]**
- - `payload.mapboxApiAccessToken` **[string][148]** mapboxApiAccessToken to be saved to mapStyle reducer
+- `payload` **[Object][154]**
+ - `payload.mapboxApiAccessToken` **[string][152]** mapboxApiAccessToken to be saved to mapStyle reducer
+ - `payload.mapboxApiUrl` **[string][152]** mapboxApiUrl to be saved to mapStyle reducer.
+ - `payload.mapStylesReplaceDefault` **[Boolean][155]** mapStylesReplaceDefault to be saved to mapStyle reducer
### receiveMapConfig
@@ -434,11 +451,17 @@ It is also useful when you want to prepare the kepler.gl instance with some pres
It will reset current configuration first then apply config to it.
- **ActionTypes**: [`ActionTypes.RECEIVE_MAP_CONFIG`][12]
-- **Updaters**: [`mapStateUpdaters.receiveMapConfigUpdater`][163], [`mapStyleUpdaters.receiveMapConfigUpdater`][164], [`visStateUpdaters.receiveMapConfigUpdater`][165]
+- **Updaters**: [`mapStateUpdaters.receiveMapConfigUpdater`][168], [`mapStyleUpdaters.receiveMapConfigUpdater`][169], [`visStateUpdaters.receiveMapConfigUpdater`][170]
**Parameters**
-- `config` **[Object][150]** **\*required** The Config Object
+- `config` **[Object][154]** **\*required** The Config Object
+- `options` **[Object][154]** **\*optional** The Option object
+ - `options.centerMap` **[boolean][155]** `default: true` if `centerMap` is set to `true` kepler.gl will
+ place the map view within the data points boundaries
+ - `options.readOnly` **[boolean][155]** `default: false` if `readOnly` is set to `true`
+ the left setting panel will be hidden
+ - `options.keepExistingConfig` **[boolean][155]** whether to keep exiting layer filter and interaction config `default: false`.
**Examples**
@@ -455,7 +478,7 @@ this.props.dispatch(receiveMapConfig(parsedConfig));
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`][12]
-- **Updaters**: [`mapStyleUpdaters.resetMapConfigMapStyleUpdater`][166], [`visStateUpdaters.resetMapConfigVisStateUpdater`][167]
+- **Updaters**: [`mapStateUpdaters.resetMapConfigUpdater`][171], [`mapStyleUpdaters.resetMapConfigMapStyleUpdater`][172], [`visStateUpdaters.resetMapConfigUpdater`][173]
## visStateActions
@@ -468,11 +491,11 @@ filters and interaction settings.
Add a new filter
- **ActionTypes**: [`ActionTypes.ADD_FILTER`][12]
-- **Updaters**: [`visStateUpdaters.addFilterUpdater`][168]
+- **Updaters**: [`visStateUpdaters.addFilterUpdater`][174]
**Parameters**
-- `dataId` **[string][148]** dataset `id` this new filter is associated with
+- `dataId` **[string][152]** dataset `id` this new filter is associated with
Returns **{type: ActionTypes.ADD_FILTER, dataId: dataId}**
@@ -481,11 +504,11 @@ Returns **{type: ActionTypes.ADD_FILTER, dataId: dataId}**
Add a new layer
- **ActionTypes**: [`ActionTypes.ADD_LAYER`][12]
-- **Updaters**: [`visStateUpdaters.addLayerUpdater`][169]
+- **Updaters**: [`visStateUpdaters.addLayerUpdater`][175]
**Parameters**
-- `props` **[Object][150]** new layer props
+- `props` **[Object][154]** new layer props
Returns **{type: ActionTypes.ADD_LAYER, props: props}**
@@ -494,11 +517,11 @@ Returns **{type: ActionTypes.ADD_LAYER, props: props}**
Show larger time filter at bottom for time playback (apply to time filter only)
- **ActionTypes**: [`ActionTypes.ENLARGE_FILTER`][12]
-- **Updaters**: [`visStateUpdaters.enlargeFilterUpdater`][170]
+- **Updaters**: [`visStateUpdaters.enlargeFilterUpdater`][176]
**Parameters**
-- `idx` **[Number][171]** index of filter to enlarge
+- `idx` **[Number][177]** index of filter to enlarge
Returns **{type: ActionTypes.ENLARGE_FILTER, idx: idx}**
@@ -507,11 +530,11 @@ Returns **{type: ActionTypes.ENLARGE_FILTER, idx: idx}**
Update `interactionConfig`
- **ActionTypes**: [`ActionTypes.INTERACTION_CONFIG_CHANGE`][12]
-- **Updaters**: [`visStateUpdaters.interactionConfigChangeUpdater`][172]
+- **Updaters**: [`visStateUpdaters.interactionConfigChangeUpdater`][178]
**Parameters**
-- `config` **[Object][150]** new config as key value map: `{tooltip: {enabled: true}}`
+- `config` **[Object][154]** new config as key value map: `{tooltip: {enabled: true}}`
Returns **{type: ActionTypes.INTERACTION_CONFIG_CHANGE, config: config}**
@@ -520,26 +543,40 @@ Returns **{type: ActionTypes.INTERACTION_CONFIG_CHANGE, config: config}**
Update layer base config: dataId, label, column, isVisible
- **ActionTypes**: [`ActionTypes.LAYER_CONFIG_CHANGE`][12]
-- **Updaters**: [`visStateUpdaters.layerConfigChangeUpdater`][173]
+- **Updaters**: [`visStateUpdaters.layerConfigChangeUpdater`][179]
**Parameters**
-- `oldLayer` **[Object][150]** layer to be updated
-- `newConfig` **[Object][150]** new config
+- `oldLayer` **[Object][154]** layer to be updated
+- `newConfig` **[Object][154]** new config
Returns **{type: ActionTypes.LAYER_CONFIG_CHANGE, oldLayer: oldLayer, newConfig: newConfig}**
+### layerTextLabelChange
+
+Update layer text label
+
+- **ActionTypes**: [`ActionTypes.LAYER_TEXT_LABEL_CHANGE`][12]
+- **Updaters**: [`visStateUpdaters.layerTextLabelChangeUpdater`][180]
+
+**Parameters**
+
+- `oldLayer` **[Object][154]** layer to be updated
+- `idx` **[Number][177]** \-`idx` of text label to be updated
+- `prop` **[string][152]** `prop` of text label, e,g, `anchor`, `alignment`, `color`, `size`, `field`
+- `value` **any** new value
+
### layerTypeChange
Update layer type. Previews layer config will be copied if applicable.
- **ActionTypes**: [`ActionTypes.LAYER_TYPE_CHANGE`][12]
-- **Updaters**: [`visStateUpdaters.layerTypeChangeUpdater`][174]
+- **Updaters**: [`visStateUpdaters.layerTypeChangeUpdater`][181]
**Parameters**
-- `oldLayer` **[Object][150]** layer to be updated
-- `newType` **[string][148]** new type
+- `oldLayer` **[Object][154]** layer to be updated
+- `newType` **[string][152]** new type
Returns **{type: ActionTypes.LAYER_TYPE_CHANGE, oldLayer: oldLayer, newType: newType}**
@@ -548,12 +585,12 @@ Returns **{type: ActionTypes.LAYER_TYPE_CHANGE, oldLayer: oldLayer, newType: new
Update layer `visConfig`
- **ActionTypes**: [`ActionTypes.LAYER_VIS_CONFIG_CHANGE`][12]
-- **Updaters**: [`visStateUpdaters.layerVisConfigChangeUpdater`][175]
+- **Updaters**: [`visStateUpdaters.layerVisConfigChangeUpdater`][182]
**Parameters**
-- `oldLayer` **[Object][150]** layer to be updated
-- `newVisConfig` **[Object][150]** new visConfig as a key value map: e.g. `{opacity: 0.8}`
+- `oldLayer` **[Object][154]** layer to be updated
+- `newVisConfig` **[Object][154]** new visConfig as a key value map: e.g. `{opacity: 0.8}`
Returns **{type: ActionTypes.LAYER_VIS_CONFIG_CHANGE, oldLayer: oldLayer, newVisConfig: newVisConfig}**
@@ -562,13 +599,13 @@ Returns **{type: ActionTypes.LAYER_VIS_CONFIG_CHANGE, oldLayer: oldLayer, newVis
Update layer visual channel
- **ActionTypes**: [`ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE`][12]
-- **Updaters**: [`visStateUpdaters.layerVisualChannelChangeUpdater`][176]
+- **Updaters**: [`visStateUpdaters.layerVisualChannelChangeUpdater`][183]
**Parameters**
-- `oldLayer` **[Object][150]** layer to be updated
-- `newConfig` **[Object][150]** new visual channel config
-- `channel` **[string][148]** channel to be updated
+- `oldLayer` **[Object][154]** layer to be updated
+- `newConfig` **[Object][154]** new visual channel config
+- `channel` **[string][152]** channel to be updated
Returns **{type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE, oldLayer: oldLayer, newConfig: newConfig, channel: channel}**
@@ -577,11 +614,11 @@ Returns **{type: ActionTypes.LAYER_VISUAL_CHANNEL_CHANGE, oldLayer: oldLayer, ne
Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed
- **ActionTypes**: [`ActionTypes.LOAD_FILES`][12]
-- **Updaters**: [`visStateUpdaters.loadFilesUpdater`][177]
+- **Updaters**: [`visStateUpdaters.loadFilesUpdater`][184]
**Parameters**
-- `files` **[Array][160]<[Object][150]>** array of fileblob
+- `files` **[Array][164]<[Object][154]>** array of fileblob
Returns **{type: ActionTypes.LOAD_FILES, files: any}**
@@ -590,7 +627,7 @@ Returns **{type: ActionTypes.LOAD_FILES, files: any}**
Trigger loading file error
- **ActionTypes**: [`ActionTypes.LOAD_FILES_ERR`][12]
-- **Updaters**: [`visStateUpdaters.loadFilesErrUpdater`][178]
+- **Updaters**: [`visStateUpdaters.loadFilesErrUpdater`][185]
**Parameters**
@@ -603,11 +640,11 @@ Returns **{type: ActionTypes.LOAD_FILES_ERR, error: any}**
Trigger layer click event with clicked object
- **ActionTypes**: [`ActionTypes.LAYER_CLICK`][12]
-- **Updaters**: [`visStateUpdaters.layerClickUpdater`][179]
+- **Updaters**: [`visStateUpdaters.layerClickUpdater`][186]
**Parameters**
-- `info` **[Object][150]** Object clicked, returned by deck.gl
+- `info` **[Object][154]** Object clicked, returned by deck.gl
Returns **{type: ActionTypes.LAYER_CLICK, info: info}**
@@ -616,11 +653,11 @@ Returns **{type: ActionTypes.LAYER_CLICK, info: info}**
Trigger layer hover event with hovered object
- **ActionTypes**: [`ActionTypes.LAYER_HOVER`][12]
-- **Updaters**: [`visStateUpdaters.layerHoverUpdater`][180]
+- **Updaters**: [`visStateUpdaters.layerHoverUpdater`][187]
**Parameters**
-- `info` **[Object][150]** Object hovered, returned by deck.gl
+- `info` **[Object][154]** Object hovered, returned by deck.gl
Returns **{type: ActionTypes.LAYER_HOVER, info: info}**
@@ -629,7 +666,22 @@ Returns **{type: ActionTypes.LAYER_HOVER, info: info}**
Trigger map click event, unselect clicked object
- **ActionTypes**: [`ActionTypes.MAP_CLICK`][12]
-- **Updaters**: [`visStateUpdaters.mapClickUpdater`][181]
+- **Updaters**: [`visStateUpdaters.mapClickUpdater`][188]
+
+Returns **{type: ActionTypes.MAP_CLICK}**
+
+### onMouseMove
+
+Trigger map mouse moveevent, payload would be
+React-map-gl PointerEvent
+[https://uber.github.io/react-map-gl/#/documentation/api-reference/pointer-event][189]
+
+- **ActionTypes**: [`ActionTypes.MOUSE_MOVE`][12]
+- **Updaters**: [`visStateUpdaters.mouseMoveUpdater`][190]
+
+**Parameters**
+
+- `evt` **[Object][154]** PointerEvent
Returns **{type: ActionTypes.MAP_CLICK}**
@@ -638,11 +690,11 @@ Returns **{type: ActionTypes.MAP_CLICK}**
Remove a dataset and all layers, filters, tooltip configs that based on it
- **ActionTypes**: [`ActionTypes.REMOVE_DATASET`][12]
-- **Updaters**: [`visStateUpdaters.removeDatasetUpdater`][182]
+- **Updaters**: [`visStateUpdaters.removeDatasetUpdater`][191]
**Parameters**
-- `key` **[string][148]** dataset id
+- `key` **[string][152]** dataset id
Returns **{type: ActionTypes.REMOVE_DATASET, key: key}**
@@ -651,11 +703,11 @@ Returns **{type: ActionTypes.REMOVE_DATASET, key: key}**
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`][12]
-- **Updaters**: [`visStateUpdaters.removeFilterUpdater`][183]
+- **Updaters**: [`visStateUpdaters.removeFilterUpdater`][192]
**Parameters**
-- `idx` **[Number][171]** idx of filter to be removed
+- `idx` **[Number][177]** idx of filter to be removed
Returns **{type: ActionTypes.REMOVE_FILTER, idx: idx}**
@@ -664,11 +716,11 @@ Returns **{type: ActionTypes.REMOVE_FILTER, idx: idx}**
Remove a layer
- **ActionTypes**: [`ActionTypes.REMOVE_LAYER`][12]
-- **Updaters**: [`visStateUpdaters.removeLayerUpdater`][184]
+- **Updaters**: [`visStateUpdaters.removeLayerUpdater`][193]
**Parameters**
-- `idx` **[Number][171]** idx of layer to be removed
+- `idx` **[Number][177]** idx of layer to be removed
Returns **{type: ActionTypes.REMOVE_LAYER, idx: idx}**
@@ -677,11 +729,11 @@ Returns **{type: ActionTypes.REMOVE_LAYER, idx: idx}**
Reorder layer, order is an array of layer indexes, index 0 will be the one at the bottom
- **ActionTypes**: [`ActionTypes.REORDER_LAYER`][12]
-- **Updaters**: [`visStateUpdaters.reorderLayerUpdater`][185]
+- **Updaters**: [`visStateUpdaters.reorderLayerUpdater`][194]
**Parameters**
-- `order` **[Array][160]<[Number][171]>** an array of layer indexes
+- `order` **[Array][164]<[Number][177]>** an array of layer indexes
**Examples**
@@ -698,12 +750,12 @@ Returns **{type: ActionTypes.REORDER_LAYER, order: order}**
Update filter property
- **ActionTypes**: [`ActionTypes.SET_FILTER`][12]
-- **Updaters**: [`visStateUpdaters.setFilterUpdater`][186]
+- **Updaters**: [`visStateUpdaters.setFilterUpdater`][195]
**Parameters**
-- `idx` **[Number][171]** \-`idx` of filter to be updated
-- `prop` **[string][148]** `prop` of filter, e,g, `dataId`, `name`, `value`
+- `idx` **[Number][177]** \-`idx` of filter to be updated
+- `prop` **[string][152]** `prop` of filter, e,g, `dataId`, `name`, `value`
- `value` **any** new value
Returns **{type: ActionTypes.SET_FILTER, idx: idx, prop: prop, value: value}**
@@ -713,39 +765,25 @@ Returns **{type: ActionTypes.SET_FILTER, idx: idx, prop: prop, value: value}**
Set the property of a filter plot
- **ActionTypes**: [`ActionTypes.SET_FILTER_PLOT`][12]
-- **Updaters**: [`visStateUpdaters.setFilterPlotUpdater`][187]
+- **Updaters**: [`visStateUpdaters.setFilterPlotUpdater`][196]
**Parameters**
-- `idx` **[Number][171]**
-- `newProp` **[Object][150]** key value mapping of new prop `{yAxis: 'histogram'}`
+- `idx` **[Number][177]**
+- `newProp` **[Object][154]** key value mapping of new prop `{yAxis: 'histogram'}`
Returns **{type: ActionTypes.SET_FILTER_PLOT, idx: any, newProp: any}**
-### setVisibleLayersForMap
-
-Set layers to be visible in split map
-
-- **ActionTypes**: [`ActionTypes.SET_VISIBLE_LAYERS_FOR_MAP`][12]
-- **Updaters**: [`visStateUpdaters.setVisibleLayersForMapUpdater`][188]
-
-**Parameters**
-
-- `mapIndex` **[Number][171]** index of the split map
-- `layerIds` **[Array][160]<[string][148]>** array of layer ids
-
-Returns **{type: ActionTypes.SET_VISIBLE_LAYERS_FOR_MAP, layerIndex: any, mapIndex: any}**
-
### showDatasetTable
Display dataset table in a modal
- **ActionTypes**: [`ActionTypes.SHOW_DATASET_TABLE`][12]
-- **Updaters**: [`visStateUpdaters.showDatasetTableUpdater`][189]
+- **Updaters**: [`visStateUpdaters.showDatasetTableUpdater`][197]
**Parameters**
-- `dataId` **[string][148]** dataset id to show in table
+- `dataId` **[string][152]** dataset id to show in table
Returns **{type: ActionTypes.SHOW_DATASET_TABLE, dataId: dataId}**
@@ -754,11 +792,11 @@ Returns **{type: ActionTypes.SHOW_DATASET_TABLE, dataId: dataId}**
Start and end filter animation
- **ActionTypes**: [`ActionTypes.TOGGLE_FILTER_ANIMATION`][12]
-- **Updaters**: [`visStateUpdaters.toggleFilterAnimationUpdater`][190]
+- **Updaters**: [`visStateUpdaters.toggleFilterAnimationUpdater`][198]
**Parameters**
-- `idx` **[Number][171]** idx of filter
+- `idx` **[Number][177]** idx of filter
Returns **{type: ActionTypes.TOGGLE_FILTER_ANIMATION, idx: idx}**
@@ -767,12 +805,12 @@ Returns **{type: ActionTypes.TOGGLE_FILTER_ANIMATION, idx: idx}**
Toggle visibility of a layer in a split map
- **ActionTypes**: [`ActionTypes.TOGGLE_LAYER_FOR_MAP`][12]
-- **Updaters**: [`visStateUpdaters.toggleLayerForMapUpdater`][191]
+- **Updaters**: [`visStateUpdaters.toggleLayerForMapUpdater`][199]
**Parameters**
-- `mapIndex` **[Number][171]** index of the split map
-- `layerId` **[string][148]** id of the layer
+- `mapIndex` **[Number][177]** index of the split map
+- `layerId` **[string][152]** id of the layer
Returns **{type: ActionTypes.TOGGLE_LAYER_FOR_MAP, mapIndex: any, layerId: any}**
@@ -781,12 +819,12 @@ Returns **{type: ActionTypes.TOGGLE_LAYER_FOR_MAP, mapIndex: any, layerId: any}*
Change filter animation speed
- **ActionTypes**: [`ActionTypes.UPDATE_FILTER_ANIMATION_SPEED`][12]
-- **Updaters**: [`visStateUpdaters.updateAnimationSpeedUpdater`][192]
+- **Updaters**: [`visStateUpdaters.updateAnimationSpeedUpdater`][200]
**Parameters**
-- `idx` **[Number][171]** `idx` of filter
-- `speed` **[Number][171]** `speed` to change it to. `speed` is a multiplier
+- `idx` **[Number][177]** `idx` of filter
+- `speed` **[Number][177]** `speed` to change it to. `speed` is a multiplier
Returns **{type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED, idx: idx, speed: speed}**
@@ -795,11 +833,11 @@ Returns **{type: ActionTypes.UPDATE_FILTER_ANIMATION_SPEED, idx: idx, speed: spe
Update layer blending mode
- **ActionTypes**: [`ActionTypes.UPDATE_LAYER_BLENDING`][12]
-- **Updaters**: [`visStateUpdaters.updateLayerBlendingUpdater`][193]
+- **Updaters**: [`visStateUpdaters.updateLayerBlendingUpdater`][201]
**Parameters**
-- `mode` **[string][148]** one of `additive`, `normal` and `subtractive`
+- `mode` **[string][152]** one of `additive`, `normal` and `subtractive`
Returns **{type: ActionTypes.UPDATE_LAYER_BLENDING, mode: mode}**
@@ -808,25 +846,25 @@ Returns **{type: ActionTypes.UPDATE_LAYER_BLENDING, mode: mode}**
Add new dataset to `visState`, with option to load a map config along with the datasets
- **ActionTypes**: [`ActionTypes.UPDATE_VIS_DATA`][12]
-- **Updaters**: [`combinedUpdaters.updateVisDataUpdater`][194], [`visStateUpdaters.updateVisDataUpdater`][195]
+- **Updaters**: [`combinedUpdaters.updateVisDataUpdater`][202], [`visStateUpdaters.updateVisDataUpdater`][203]
**Parameters**
-- `datasets` **([Array][160]<[Object][150]> | [Object][150])** **\*required** datasets can be a dataset or an array of datasets
+- `datasets` **([Array][164]<[Object][154]> | [Object][154])** **\*required** datasets can be a dataset or an array of datasets
Each dataset object needs to have `info` and `data` property.
- - `datasets.info` **[Object][150]** \-info of a dataset
- - `datasets.info.id` **[string][148]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- - `datasets.info.label` **[string][148]** A display name of this dataset
- - `datasets.data` **[Object][150]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
- - `datasets.data.fields` **[Array][160]<[Object][150]>** **\*required** Array of fields,
- - `datasets.data.fields.name` **[string][148]** **\*required** Name of the field,
- - `datasets.data.rows` **[Array][160]<[Array][160]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
-- `options` **[Object][150]**
- - `options.centerMap` **[boolean][151]** `default: true` if `centerMap` is set to `true` kepler.gl will
+ - `datasets.info` **[Object][154]** \-info of a dataset
+ - `datasets.info.id` **[string][152]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ - `datasets.info.label` **[string][152]** A display name of this dataset
+ - `datasets.data` **[Object][154]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ - `datasets.data.fields` **[Array][164]<[Object][154]>** **\*required** Array of fields,
+ - `datasets.data.fields.name` **[string][152]** **\*required** Name of the field,
+ - `datasets.data.rows` **[Array][164]<[Array][164]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
+- `options` **[Object][154]**
+ - `options.centerMap` **[boolean][155]** `default: true` if `centerMap` is set to `true` kepler.gl will
place the map view within the data points boundaries
- - `options.readOnly` **[boolean][151]** `default: false` if `readOnly` is set to `true`
+ - `options.readOnly` **[boolean][155]** `default: false` if `readOnly` is set to `true`
the left setting panel will be hidden
-- `config` **[Object][150]** this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
+- `config` **[Object][154]** 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}**
@@ -842,194 +880,194 @@ It also manges which settings are selected during image and map export
Add a notification to be displayed
- **ActionTypes**: [`ActionTypes.ADD_NOTIFICATION`][12]
-- **Updaters**: [`uiStateUpdaters.addNotificationUpdater`][196]
+- **Updaters**: [`uiStateUpdaters.addNotificationUpdater`][204]
**Parameters**
-- `notification` **[Object][150]** The `notification` object to be added
+- `notification` **[Object][154]** The `notification` object to be added
### cleanupExportImage
Delete cached export image
- **ActionTypes**: [`ActionTypes.CLEANUP_EXPORT_IMAGE`][12]
-- **Updaters**: [`uiStateUpdaters.cleanupExportImage`][197]
+- **Updaters**: [`uiStateUpdaters.cleanupExportImage`][205]
### hideExportDropdown
Hide side panel header dropdown, activated by clicking the share link on top of the side panel
- **ActionTypes**: [`ActionTypes.HIDE_EXPORT_DROPDOWN`][12]
-- **Updaters**: [`uiStateUpdaters.hideExportDropdownUpdater`][198]
+- **Updaters**: [`uiStateUpdaters.hideExportDropdownUpdater`][206]
### openDeleteModal
Toggle active map control panel
- **ActionTypes**: [`ActionTypes.OPEN_DELETE_MODAL`][12]
-- **Updaters**: [`uiStateUpdaters.openDeleteModalUpdater`][199]
+- **Updaters**: [`uiStateUpdaters.openDeleteModalUpdater`][207]
**Parameters**
-- `datasetId` **[string][148]** `id` of the dataset to be deleted
+- `datasetId` **[string][152]** `id` of the dataset to be deleted
### removeNotification
Remove a notification
- **ActionTypes**: [`ActionTypes.REMOVE_NOTIFICATION`][12]
-- **Updaters**: [`uiStateUpdaters.removeNotificationUpdater`][200]
+- **Updaters**: [`uiStateUpdaters.removeNotificationUpdater`][208]
**Parameters**
-- `id` **[string][148]** `id` of the notification to be removed
+- `id` **[string][152]** `id` of the notification to be removed
### setExportData
Whether to including data in map config, toggle between `true` or `false`
- **ActionTypes**: [`ActionTypes.SET_EXPORT_DATA`][12]
-- **Updaters**: [`uiStateUpdaters.setExportDataUpdater`][201]
+- **Updaters**: [`uiStateUpdaters.setExportDataUpdater`][209]
### setExportDataType
Set data format for exporting data
- **ActionTypes**: [`ActionTypes.SET_EXPORT_DATA_TYPE`][12]
-- **Updaters**: [`uiStateUpdaters.setExportDataTypeUpdater`][202]
+- **Updaters**: [`uiStateUpdaters.setExportDataTypeUpdater`][210]
**Parameters**
-- `dataType` **[string][148]** one of `'text/csv'`
+- `dataType` **[string][152]** one of `'text/csv'`
### setExportFiltered
Whether to export filtered data, `true` or `false`
- **ActionTypes**: [`ActionTypes.SET_EXPORT_FILTERED`][12]
-- **Updaters**: [`uiStateUpdaters.setExportFilteredUpdater`][203]
+- **Updaters**: [`uiStateUpdaters.setExportFilteredUpdater`][211]
**Parameters**
-- `payload` **[boolean][151]** set `true` to ony export filtered data
+- `payload` **[boolean][155]** set `true` to ony export filtered data
### setExportImageDataUri
Set `exportImage.setExportImageDataUri` to a dataUri
- **ActionTypes**: [`ActionTypes.SET_EXPORT_IMAGE_DATA_URI`][12]
-- **Updaters**: [`uiStateUpdaters.setExportImageDataUri`][204]
+- **Updaters**: [`uiStateUpdaters.setExportImageDataUri`][212]
**Parameters**
-- `dataUri` **[string][148]** export image data uri
+- `dataUri` **[string][152]** export image data uri
### setExportSelectedDataset
Set selected dataset for export
- **ActionTypes**: [`ActionTypes.SET_EXPORT_SELECTED_DATASET`][12]
-- **Updaters**: [`uiStateUpdaters.setExportSelectedDatasetUpdater`][205]
+- **Updaters**: [`uiStateUpdaters.setExportSelectedDatasetUpdater`][213]
**Parameters**
-- `datasetId` **[string][148]** dataset id
+- `datasetId` **[string][152]** dataset id
### setRatio
Set `exportImage.ratio`
- **ActionTypes**: [`ActionTypes.SET_RATIO`][12]
-- **Updaters**: [`uiStateUpdaters.setRatioUpdater`][206]
+- **Updaters**: [`uiStateUpdaters.setRatioUpdater`][214]
**Parameters**
-- `ratio` **[string][148]** one of `'SCREEN'`, `'FOUR_BY_THREE'` and `'SIXTEEN_BY_NINE'`
+- `ratio` **[string][152]** one of `'SCREEN'`, `'FOUR_BY_THREE'` and `'SIXTEEN_BY_NINE'`
### setResolution
Set `exportImage.resolution`
- **ActionTypes**: [`ActionTypes.SET_RESOLUTION`][12]
-- **Updaters**: [`uiStateUpdaters.setResolutionUpdater`][207]
+- **Updaters**: [`uiStateUpdaters.setResolutionUpdater`][215]
**Parameters**
-- `resolution` **[string][148]** one of `'ONE_X'`, `'TWO_X'`
+- `resolution` **[string][152]** one of `'ONE_X'`, `'TWO_X'`
### setUserMapboxAccessToken
Whether we export a mapbox access token used to create a single map html file
- **ActionTypes**: [`ActionTypes.SET_USER_MAPBOX_ACCESS_TOKEN`][12]
-- **Updaters**: [`uiStateUpdaters.setUserMapboxAccessTokenUpdater`][208]
+- **Updaters**: [`uiStateUpdaters.setUserMapboxAccessTokenUpdater`][216]
**Parameters**
-- `payload` **[string][148]** mapbox access token
+- `payload` **[string][152]** 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`][12]
-- **Updaters**: [`uiStateUpdaters.showExportDropdownUpdater`][209]
+- **Updaters**: [`uiStateUpdaters.showExportDropdownUpdater`][217]
**Parameters**
-- `id` **[string][148]** id of the dropdown
+- `id` **[string][152]** id of the dropdown
### startExportingImage
Set `exportImage.exporting` to true
- **ActionTypes**: [`ActionTypes.START_EXPORTING_IMAGE`][12]
-- **Updaters**: [`uiStateUpdaters.startExportingImage`][210]
+- **Updaters**: [`uiStateUpdaters.startExportingImage`][218]
### toggleLegend
Set `exportImage.legend` to true or false
- **ActionTypes**: [`ActionTypes.TOGGLE_LEGEND`][12]
-- **Updaters**: [`uiStateUpdaters.toggleLegendUpdater`][211]
+- **Updaters**: [`uiStateUpdaters.toggleLegendUpdater`][219]
### toggleMapControl
Toggle active map control panel
- **ActionTypes**: [`ActionTypes.TOGGLE_MAP_CONTROL`][12]
-- **Updaters**: [`uiStateUpdaters.toggleMapControlUpdater`][212]
+- **Updaters**: [`uiStateUpdaters.toggleMapControlUpdater`][220]
**Parameters**
-- `panelId` **[string][148]** map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`][213]
+- `panelId` **[string][152]** map control panel id, one of the keys of: [`DEFAULT_MAP_CONTROLS`][221]
### toggleModal
Show and hide modal dialog
- **ActionTypes**: [`ActionTypes.TOGGLE_MODAL`][12]
-- **Updaters**: [`uiStateUpdaters.toggleModalUpdater`][214]
+- **Updaters**: [`uiStateUpdaters.toggleModalUpdater`][222]
**Parameters**
-- `id` **([string][148] | null)** id of modal to be shown, null to hide modals. One of:- [`DATA_TABLE_ID`][215]
- - [`DELETE_DATA_ID`][216]
- - [`ADD_DATA_ID`][217]
- - [`EXPORT_IMAGE_ID`][218]
- - [`EXPORT_DATA_ID`][219]
- - [`ADD_MAP_STYLE_ID`][220]
+- `id` **([string][152] | null)** id of modal to be shown, null to hide modals. One of:- [`DATA_TABLE_ID`][223]
+ - [`DELETE_DATA_ID`][224]
+ - [`ADD_DATA_ID`][225]
+ - [`EXPORT_IMAGE_ID`][226]
+ - [`EXPORT_DATA_ID`][227]
+ - [`ADD_MAP_STYLE_ID`][228]
### toggleSidePanel
Toggle active side panel
- **ActionTypes**: [`ActionTypes.TOGGLE_SIDE_PANEL`][12]
-- **Updaters**: [`uiStateUpdaters.toggleSidePanelUpdater`][221]
+- **Updaters**: [`uiStateUpdaters.toggleSidePanelUpdater`][229]
**Parameters**
-- `id` **[string][148]** id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`
+- `id` **[string][152]** id of side panel to be shown, one of `layer`, `filter`, `interaction`, `map`
## rootActions
@@ -1050,7 +1088,7 @@ the instance state and later transfer it to a newly mounted component with the s
**Parameters**
-- `id` **[string][148]** the id of the instance to be deleted
+- `id` **[string][152]** the id of the instance to be deleted
### registerEntry
@@ -1063,11 +1101,13 @@ performed. Instance reducer can only handle actions when it is instantiated.
**Parameters**
-- `payload` **[Object][150]**
- - `payload.id` **[string][148]** **\*required** The id of the instance
- - `payload.mint` **[boolean][151]** Whether to use a fresh empty state, when `mint: true` it will _always_ load a fresh state when the component is re-mounted.
+- `payload` **[Object][154]**
+ - `payload.id` **[string][152]** **\*required** The id of the instance
+ - `payload.mint` **[boolean][155]** 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` **[string][148]** mapboxApiAccessToken to be saved in `map-style` reducer.
+ - `payload.mapboxApiAccessToken` **[string][152]** mapboxApiAccessToken to be saved in `map-style` reducer.
+ - `payload.mapboxApiUrl` **[string][152]** mapboxApiUrl to be saved in `map-style` reducer.
+ - `payload.mapStylesReplaceDefault` **[Boolean][155]** mapStylesReplaceDefault to be saved in `map-style` reducer.
### renameEntry
@@ -1078,8 +1118,8 @@ Rename an instance in the root reducer, keep its entire state
**Parameters**
-- `oldId` **[string][148]** **\*required** old id
-- `newId` **[string][148]** **\*required** new id
+- `oldId` **[string][152]** **\*required** old id
+- `newId` **[string][152]** **\*required** new id
## mapStateActions
@@ -1092,11 +1132,11 @@ toggle between single and split maps.
Fit map viewport to bounds
- **ActionTypes**: [`ActionTypes.FIT_BOUNDS`][12]
-- **Updaters**: [`mapStateUpdaters.fitBoundsUpdater`][222]
+- **Updaters**: [`mapStateUpdaters.fitBoundsUpdater`][230]
**Parameters**
-- `bounds` **[Array][160]<[Number][171]>** as `[lngMin, latMin, lngMax, latMax]`
+- `bounds` **[Array][164]<[Number][177]>** as `[lngMin, latMin, lngMax, latMax]`
**Examples**
@@ -1110,7 +1150,7 @@ this.props.dispatch(fitBounds([-122.23, 37.127, -122.11, 37.456]));
Toggle between 3d and 2d map.
- **ActionTypes**: [`ActionTypes.TOGGLE_PERSPECTIVE`][12]
-- **Updaters**: [`mapStateUpdaters.togglePerspectiveUpdater`][223]
+- **Updaters**: [`mapStateUpdaters.togglePerspectiveUpdater`][231]
**Examples**
@@ -1124,11 +1164,11 @@ this.props.dispatch(togglePerspective());
Toggle between single map or split maps
- **ActionTypes**: [`ActionTypes.TOGGLE_SPLIT_MAP`][12]
-- **Updaters**: [`mapStateUpdaters.toggleSplitMapUpdater`][224], [`visStateUpdaters.toggleSplitMapUpdater`][225]
+- **Updaters**: [`mapStateUpdaters.toggleSplitMapUpdater`][232], [`visStateUpdaters.toggleSplitMapUpdater`][233]
**Parameters**
-- `index` **[Number][171]?** index is provided, close split map at index
+- `index` **[Number][177]?** index is provided, close split map at index
**Examples**
@@ -1142,19 +1182,19 @@ this.props.dispatch(toggleSplitMap());
Update map viewport
- **ActionTypes**: [`ActionTypes.UPDATE_MAP`][12]
-- **Updaters**: [`mapStateUpdaters.updateMapUpdater`][226]
+- **Updaters**: [`mapStateUpdaters.updateMapUpdater`][234]
**Parameters**
-- `viewport` **[Object][150]** viewport object container one or any of these properties `width`, `height`, `latitude` `longitude`, `zoom`, `pitch`, `bearing`, `dragRotate`
- - `viewport.width` **[Number][171]?** Width of viewport
- - `viewport.height` **[Number][171]?** Height of viewport
- - `viewport.zoom` **[Number][171]?** Zoom of viewport
- - `viewport.pitch` **[Number][171]?** Camera angle in degrees (0 is straight down)
- - `viewport.bearing` **[Number][171]?** Map rotation in degrees (0 means north is up)
- - `viewport.latitude` **[Number][171]?** Latitude center of viewport on map in mercator projection
- - `viewport.longitude` **[Number][171]?** Longitude Center of viewport on map in mercator projection
- - `viewport.dragRotate` **[boolean][151]?** Whether to enable drag and rotate map into perspective viewport
+- `viewport` **[Object][154]** viewport object container one or any of these properties `width`, `height`, `latitude` `longitude`, `zoom`, `pitch`, `bearing`, `dragRotate`
+ - `viewport.width` **[Number][177]?** Width of viewport
+ - `viewport.height` **[Number][177]?** Height of viewport
+ - `viewport.zoom` **[Number][177]?** Zoom of viewport
+ - `viewport.pitch` **[Number][177]?** Camera angle in degrees (0 is straight down)
+ - `viewport.bearing` **[Number][177]?** Map rotation in degrees (0 means north is up)
+ - `viewport.latitude` **[Number][177]?** Latitude center of viewport on map in mercator projection
+ - `viewport.longitude` **[Number][177]?** Longitude Center of viewport on map in mercator projection
+ - `viewport.dragRotate` **[boolean][155]?** Whether to enable drag and rotate map into perspective viewport
**Examples**
@@ -1168,11 +1208,11 @@ this.props.dispatch(updateMap({latitude: 37.75043, longitude: -122.34679, width:
Set the expor tmap format (html, json)
- **ActionTypes**: [`ActionTypes.SET_EXPORT_MAP_FORMAT`][12]
-- **Updaters**: [`uiStateUpdaters.setExportMapFormat`][227]
+- **Updaters**: [`uiStateUpdaters.setExportMapFormat`][235]
**Parameters**
-- `payload` **[string][148]** map format
+- `payload` **[string][152]** map format
[1]: #forwardactions
@@ -1232,398 +1272,414 @@ Set the expor tmap format (html, json)
[29]: #parameters-10
-[30]: #main
+[30]: #set3dbuildingcolor
-[31]: #adddatatomap
+[31]: #parameters-11
-[32]: #parameters-11
+[32]: #main
-[33]: #examples-3
+[33]: #adddatatomap
-[34]: #keplerglinit
+[34]: #parameters-12
-[35]: #parameters-12
+[35]: #examples-3
-[36]: #receivemapconfig
+[36]: #keplerglinit
[37]: #parameters-13
-[38]: #examples-4
+[38]: #receivemapconfig
-[39]: #resetmapconfig
+[39]: #parameters-14
-[40]: #visstateactions
+[40]: #examples-4
-[41]: #addfilter
+[41]: #resetmapconfig
-[42]: #parameters-14
+[42]: #visstateactions
-[43]: #addlayer
+[43]: #addfilter
[44]: #parameters-15
-[45]: #enlargefilter
+[45]: #addlayer
[46]: #parameters-16
-[47]: #interactionconfigchange
+[47]: #enlargefilter
[48]: #parameters-17
-[49]: #layerconfigchange
+[49]: #interactionconfigchange
[50]: #parameters-18
-[51]: #layertypechange
+[51]: #layerconfigchange
[52]: #parameters-19
-[53]: #layervisconfigchange
+[53]: #layertextlabelchange
[54]: #parameters-20
-[55]: #layervisualchannelconfigchange
+[55]: #layertypechange
[56]: #parameters-21
-[57]: #loadfiles
+[57]: #layervisconfigchange
[58]: #parameters-22
-[59]: #loadfileserr
+[59]: #layervisualchannelconfigchange
[60]: #parameters-23
-[61]: #onlayerclick
+[61]: #loadfiles
[62]: #parameters-24
-[63]: #onlayerhover
+[63]: #loadfileserr
[64]: #parameters-25
-[65]: #onmapclick
+[65]: #onlayerclick
-[66]: #removedataset
+[66]: #parameters-26
-[67]: #parameters-26
+[67]: #onlayerhover
-[68]: #removefilter
+[68]: #parameters-27
-[69]: #parameters-27
+[69]: #onmapclick
-[70]: #removelayer
+[70]: #onmousemove
[71]: #parameters-28
-[72]: #reorderlayer
+[72]: #removedataset
[73]: #parameters-29
-[74]: #examples-5
+[74]: #removefilter
-[75]: #setfilter
+[75]: #parameters-30
-[76]: #parameters-30
+[76]: #removelayer
-[77]: #setfilterplot
+[77]: #parameters-31
-[78]: #parameters-31
+[78]: #reorderlayer
-[79]: #setvisiblelayersformap
+[79]: #parameters-32
-[80]: #parameters-32
+[80]: #examples-5
-[81]: #showdatasettable
+[81]: #setfilter
[82]: #parameters-33
-[83]: #toggleanimation
+[83]: #setfilterplot
[84]: #parameters-34
-[85]: #togglelayerformap
+[85]: #showdatasettable
[86]: #parameters-35
-[87]: #updateanimationspeed
+[87]: #toggleanimation
[88]: #parameters-36
-[89]: #updatelayerblending
+[89]: #togglelayerformap
[90]: #parameters-37
-[91]: #updatevisdata
+[91]: #updateanimationspeed
[92]: #parameters-38
-[93]: #uistateactions
+[93]: #updatelayerblending
-[94]: #addnotification
+[94]: #parameters-39
-[95]: #parameters-39
+[95]: #updatevisdata
-[96]: #cleanupexportimage
+[96]: #parameters-40
-[97]: #hideexportdropdown
+[97]: #uistateactions
-[98]: #opendeletemodal
+[98]: #addnotification
-[99]: #parameters-40
+[99]: #parameters-41
-[100]: #removenotification
+[100]: #cleanupexportimage
-[101]: #parameters-41
+[101]: #hideexportdropdown
-[102]: #setexportdata
+[102]: #opendeletemodal
-[103]: #setexportdatatype
+[103]: #parameters-42
-[104]: #parameters-42
+[104]: #removenotification
-[105]: #setexportfiltered
+[105]: #parameters-43
-[106]: #parameters-43
+[106]: #setexportdata
-[107]: #setexportimagedatauri
+[107]: #setexportdatatype
[108]: #parameters-44
-[109]: #setexportselecteddataset
+[109]: #setexportfiltered
[110]: #parameters-45
-[111]: #setratio
+[111]: #setexportimagedatauri
[112]: #parameters-46
-[113]: #setresolution
+[113]: #setexportselecteddataset
[114]: #parameters-47
-[115]: #setusermapboxaccesstoken
+[115]: #setratio
[116]: #parameters-48
-[117]: #showexportdropdown
+[117]: #setresolution
[118]: #parameters-49
-[119]: #startexportingimage
+[119]: #setusermapboxaccesstoken
-[120]: #togglelegend
+[120]: #parameters-50
-[121]: #togglemapcontrol
+[121]: #showexportdropdown
-[122]: #parameters-50
+[122]: #parameters-51
-[123]: #togglemodal
+[123]: #startexportingimage
-[124]: #parameters-51
+[124]: #togglelegend
-[125]: #togglesidepanel
+[125]: #togglemapcontrol
[126]: #parameters-52
-[127]: #rootactions
+[127]: #togglemodal
-[128]: #deleteentry
+[128]: #parameters-53
-[129]: #parameters-53
+[129]: #togglesidepanel
-[130]: #registerentry
+[130]: #parameters-54
-[131]: #parameters-54
+[131]: #rootactions
-[132]: #renameentry
+[132]: #deleteentry
[133]: #parameters-55
-[134]: #mapstateactions
+[134]: #registerentry
+
+[135]: #parameters-56
+
+[136]: #renameentry
+
+[137]: #parameters-57
+
+[138]: #mapstateactions
+
+[139]: #fitbounds
+
+[140]: #parameters-58
+
+[141]: #examples-6
+
+[142]: #toggleperspective
-[135]: #fitbounds
+[143]: #examples-7
-[136]: #parameters-56
+[144]: #togglesplitmap
-[137]: #examples-6
+[145]: #parameters-59
-[138]: #toggleperspective
+[146]: #examples-8
-[139]: #examples-7
+[147]: #updatemap
-[140]: #togglesplitmap
+[148]: #parameters-60
-[141]: #parameters-57
+[149]: #examples-9
-[142]: #examples-8
+[150]: #setexportmapformat
-[143]: #updatemap
+[151]: #parameters-61
-[144]: #parameters-58
+[152]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
-[145]: #examples-9
+[153]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
-[146]: #setexportmapformat
+[154]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
-[147]: #parameters-59
+[155]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
-[148]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
+[156]: ../reducers/map-style.md#mapstyleupdatersaddcustommapstyleupdater
-[149]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
+[157]: ../reducers/map-style.md#mapstyleupdatersinputmapstyleupdater
-[150]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
+[158]: ../reducers/map-style.md#mapstyleupdatersloadcustommapstyleupdater
-[151]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
+[159]: ../reducers/map-style.md#mapstyleupdatersloadmapstyleerrupdater
-[152]: ../reducers/map-style.md#mapstyleupdatersaddcustommapstyleupdater
+[160]: ../reducers/map-style.md#mapstyleupdatersloadmapstylesupdater
-[153]: ../reducers/map-style.md#mapstyleupdatersinputmapstyleupdater
+[161]: ../reducers/map-style.md#mapstyleupdatersmapconfigchangeupdater
-[154]: ../reducers/map-style.md#mapstyleupdatersloadcustommapstyleupdater
+[162]: ../reducers/map-style.md#mapstyleupdatersmapstylechangeupdater
-[155]: ../reducers/map-style.md#mapstyleupdatersloadmapstyleerrupdater
+[163]: ../reducers/map-style.md#mapstyleupdatersrequestmapstylesupdater
-[156]: ../reducers/map-style.md#mapstyleupdatersloadmapstylesupdater
+[164]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
-[157]: ../reducers/map-style.md#mapstyleupdatersmapconfigchangeupdater
+[165]: ../reducers/map-style.md#mapstyleupdatersset3dbuildingcolorupdater
-[158]: ../reducers/map-style.md#mapstyleupdatersmapstylechangeupdater
+[166]: ../reducers/composers.md#combinedupdatersadddatatomapupdater
-[159]: ../reducers/map-style.md#mapstyleupdatersrequestmapstylesupdater
+[167]: ../reducers/map-style.md#mapstyleupdatersinitmapstyleupdater
-[160]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
+[168]: ../reducers/map-state.md#mapstateupdatersreceivemapconfigupdater
-[161]: ../reducers/composers.md#combinedupdatersadddatatomapupdater
+[169]: ../reducers/map-style.md#mapstyleupdatersreceivemapconfigupdater
-[162]: ../reducers/map-style.md#mapstyleupdatersinitmapstyleupdater
+[170]: ../reducers/vis-state.md#visstateupdatersreceivemapconfigupdater
-[163]: ../reducers/map-state.md#mapstateupdatersreceivemapconfigupdater
+[171]: ../reducers/map-state.md#mapstateupdatersresetmapconfigupdater
-[164]: ../reducers/map-style.md#mapstyleupdatersreceivemapconfigupdater
+[172]: ../reducers/map-style.md#mapstyleupdatersresetmapconfigmapstyleupdater
-[165]: ../reducers/vis-state.md#visstateupdatersreceivemapconfigupdater
+[173]: ../reducers/vis-state.md#visstateupdatersresetmapconfigupdater
-[166]: ../reducers/map-style.md#mapstyleupdatersresetmapconfigmapstyleupdater
+[174]: ../reducers/vis-state.md#visstateupdatersaddfilterupdater
-[167]: ../reducers/vis-state.md#visstateupdatersresetmapconfigvisstateupdater
+[175]: ../reducers/vis-state.md#visstateupdatersaddlayerupdater
-[168]: ../reducers/vis-state.md#visstateupdatersaddfilterupdater
+[176]: ../reducers/vis-state.md#visstateupdatersenlargefilterupdater
-[169]: ../reducers/vis-state.md#visstateupdatersaddlayerupdater
+[177]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
-[170]: ../reducers/vis-state.md#visstateupdatersenlargefilterupdater
+[178]: ../reducers/vis-state.md#visstateupdatersinteractionconfigchangeupdater
-[171]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
+[179]: ../reducers/vis-state.md#visstateupdaterslayerconfigchangeupdater
-[172]: ../reducers/vis-state.md#visstateupdatersinteractionconfigchangeupdater
+[180]: ../reducers/vis-state.md#visstateupdaterslayertextlabelchangeupdater
-[173]: ../reducers/vis-state.md#visstateupdaterslayerconfigchangeupdater
+[181]: ../reducers/vis-state.md#visstateupdaterslayertypechangeupdater
-[174]: ../reducers/vis-state.md#visstateupdaterslayertypechangeupdater
+[182]: ../reducers/vis-state.md#visstateupdaterslayervisconfigchangeupdater
-[175]: ../reducers/vis-state.md#visstateupdaterslayervisconfigchangeupdater
+[183]: ../reducers/vis-state.md#visstateupdaterslayervisualchannelchangeupdater
-[176]: ../reducers/vis-state.md#visstateupdaterslayervisualchannelchangeupdater
+[184]: ../reducers/vis-state.md#visstateupdatersloadfilesupdater
-[177]: ../reducers/vis-state.md#visstateupdatersloadfilesupdater
+[185]: ../reducers/vis-state.md#visstateupdatersloadfileserrupdater
-[178]: ../reducers/vis-state.md#visstateupdatersloadfileserrupdater
+[186]: ../reducers/vis-state.md#visstateupdaterslayerclickupdater
-[179]: ../reducers/vis-state.md#visstateupdaterslayerclickupdater
+[187]: ../reducers/vis-state.md#visstateupdaterslayerhoverupdater
-[180]: ../reducers/vis-state.md#visstateupdaterslayerhoverupdater
+[188]: ../reducers/vis-state.md#visstateupdatersmapclickupdater
-[181]: ../reducers/vis-state.md#visstateupdatersmapclickupdater
+[189]: https://uber.github.io/react-map-gl/#/documentation/api-reference/pointer-event
-[182]: ../reducers/vis-state.md#visstateupdatersremovedatasetupdater
+[190]: ../reducers/vis-state.md#visstateupdatersmousemoveupdater
-[183]: ../reducers/vis-state.md#visstateupdatersremovefilterupdater
+[191]: ../reducers/vis-state.md#visstateupdatersremovedatasetupdater
-[184]: ../reducers/vis-state.md#visstateupdatersremovelayerupdater
+[192]: ../reducers/vis-state.md#visstateupdatersremovefilterupdater
-[185]: ../reducers/vis-state.md#visstateupdatersreorderlayerupdater
+[193]: ../reducers/vis-state.md#visstateupdatersremovelayerupdater
-[186]: ../reducers/vis-state.md#visstateupdaterssetfilterupdater
+[194]: ../reducers/vis-state.md#visstateupdatersreorderlayerupdater
-[187]: ../reducers/vis-state.md#visstateupdaterssetfilterplotupdater
+[195]: ../reducers/vis-state.md#visstateupdaterssetfilterupdater
-[188]: ../reducers/vis-state.md#visstateupdaterssetvisiblelayersformapupdater
+[196]: ../reducers/vis-state.md#visstateupdaterssetfilterplotupdater
-[189]: ../reducers/vis-state.md#visstateupdatersshowdatasettableupdater
+[197]: ../reducers/vis-state.md#visstateupdatersshowdatasettableupdater
-[190]: ../reducers/vis-state.md#visstateupdaterstogglefilteranimationupdater
+[198]: ../reducers/vis-state.md#visstateupdaterstogglefilteranimationupdater
-[191]: ../reducers/vis-state.md#visstateupdaterstogglelayerformapupdater
+[199]: ../reducers/vis-state.md#visstateupdaterstogglelayerformapupdater
-[192]: ../reducers/vis-state.md#visstateupdatersupdateanimationspeedupdater
+[200]: ../reducers/vis-state.md#visstateupdatersupdateanimationspeedupdater
-[193]: ../reducers/vis-state.md#visstateupdatersupdatelayerblendingupdater
+[201]: ../reducers/vis-state.md#visstateupdatersupdatelayerblendingupdater
-[194]: ../reducers/composers.md#combinedupdatersupdatevisdataupdater
+[202]: ../reducers/composers.md#combinedupdatersupdatevisdataupdater
-[195]: ../reducers/vis-state.md#visstateupdatersupdatevisdataupdater
+[203]: ../reducers/vis-state.md#visstateupdatersupdatevisdataupdater
-[196]: ../reducers/ui-state.md#uistateupdatersaddnotificationupdater
+[204]: ../reducers/ui-state.md#uistateupdatersaddnotificationupdater
-[197]: ../reducers/ui-state.md#uistateupdaterscleanupexportimage
+[205]: ../reducers/ui-state.md#uistateupdaterscleanupexportimage
-[198]: ../reducers/ui-state.md#uistateupdatershideexportdropdownupdater
+[206]: ../reducers/ui-state.md#uistateupdatershideexportdropdownupdater
-[199]: ../reducers/ui-state.md#uistateupdatersopendeletemodalupdater
+[207]: ../reducers/ui-state.md#uistateupdatersopendeletemodalupdater
-[200]: ../reducers/ui-state.md#uistateupdatersremovenotificationupdater
+[208]: ../reducers/ui-state.md#uistateupdatersremovenotificationupdater
-[201]: ../reducers/ui-state.md#uistateupdaterssetexportdataupdater
+[209]: ../reducers/ui-state.md#uistateupdaterssetexportdataupdater
-[202]: ../reducers/ui-state.md#uistateupdaterssetexportdatatypeupdater
+[210]: ../reducers/ui-state.md#uistateupdaterssetexportdatatypeupdater
-[203]: ../reducers/ui-state.md#uistateupdaterssetexportfilteredupdater
+[211]: ../reducers/ui-state.md#uistateupdaterssetexportfilteredupdater
-[204]: ../reducers/ui-state.md#uistateupdaterssetexportimagedatauri
+[212]: ../reducers/ui-state.md#uistateupdaterssetexportimagedatauri
-[205]: ../reducers/ui-state.md#uistateupdaterssetexportselecteddatasetupdater
+[213]: ../reducers/ui-state.md#uistateupdaterssetexportselecteddatasetupdater
-[206]: ../reducers/ui-state.md#uistateupdaterssetratioupdater
+[214]: ../reducers/ui-state.md#uistateupdaterssetratioupdater
-[207]: ../reducers/ui-state.md#uistateupdaterssetresolutionupdater
+[215]: ../reducers/ui-state.md#uistateupdaterssetresolutionupdater
-[208]: ../reducers/ui-state.md#uistateupdaterssetusermapboxaccesstokenupdater
+[216]: ../reducers/ui-state.md#uistateupdaterssetusermapboxaccesstokenupdater
-[209]: ../reducers/ui-state.md#uistateupdatersshowexportdropdownupdater
+[217]: ../reducers/ui-state.md#uistateupdatersshowexportdropdownupdater
-[210]: ../reducers/ui-state.md#uistateupdatersstartexportingimage
+[218]: ../reducers/ui-state.md#uistateupdatersstartexportingimage
-[211]: ../reducers/ui-state.md#uistateupdaterstogglelegendupdater
+[219]: ../reducers/ui-state.md#uistateupdaterstogglelegendupdater
-[212]: ../reducers/ui-state.md#uistateupdaterstogglemapcontrolupdater
+[220]: ../reducers/ui-state.md#uistateupdaterstogglemapcontrolupdater
-[213]: #default_map_controls
+[221]: #default_map_controls
-[214]: ../reducers/ui-state.md#uistateupdaterstogglemodalupdater
+[222]: ../reducers/ui-state.md#uistateupdaterstogglemodalupdater
-[215]: ../constants/default-settings.md#data_table_id
+[223]: ../constants/default-settings.md#data_table_id
-[216]: ../constants/default-settings.md#delete_data_id
+[224]: ../constants/default-settings.md#delete_data_id
-[217]: ../constants/default-settings.md#add_data_id
+[225]: ../constants/default-settings.md#add_data_id
-[218]: ../constants/default-settings.md#export_image_id
+[226]: ../constants/default-settings.md#export_image_id
-[219]: ../constants/default-settings.md#export_data_id
+[227]: ../constants/default-settings.md#export_data_id
-[220]: ../constants/default-settings.md#add_map_style_id
+[228]: ../constants/default-settings.md#add_map_style_id
-[221]: ../reducers/ui-state.md#uistateupdaterstogglesidepanelupdater
+[229]: ../reducers/ui-state.md#uistateupdaterstogglesidepanelupdater
-[222]: ../reducers/map-state.md#mapstateupdatersfitboundsupdater
+[230]: ../reducers/map-state.md#mapstateupdatersfitboundsupdater
-[223]: ../reducers/map-state.md#mapstateupdaterstoggleperspectiveupdater
+[231]: ../reducers/map-state.md#mapstateupdaterstoggleperspectiveupdater
-[224]: ../reducers/map-state.md#mapstateupdaterstogglesplitmapupdater
+[232]: ../reducers/map-state.md#mapstateupdaterstogglesplitmapupdater
-[225]: ../reducers/vis-state.md#visstateupdaterstogglesplitmapupdater
+[233]: ../reducers/vis-state.md#visstateupdaterstogglesplitmapupdater
-[226]: ../reducers/map-state.md#mapstateupdatersupdatemapupdater
+[234]: ../reducers/map-state.md#mapstateupdatersupdatemapupdater
-[227]: ../reducers/ui-state.md#uistateupdaterssetexportmapformat
+[235]: ../reducers/ui-state.md#uistateupdaterssetexportmapformat
diff --git a/docs/api-reference/reducers/combine.md b/docs/api-reference/reducers/combine.md
index cdbe58782..48dd1889d 100644
--- a/docs/api-reference/reducers/combine.md
+++ b/docs/api-reference/reducers/combine.md
@@ -4,13 +4,12 @@
- [combinedUpdaters][1]
- [addDataToMapUpdater][3]
- - [updateVisDataUpdater][5]
## 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 [Using updaters][7]
+as the first argument. Read more about [Using updaters][5]
**Examples**
@@ -54,52 +53,26 @@ export default composedReducer;
Combine data and full configuration update in a single action
-- **Action**: [`addDataToMap`][8]
+- **Action**: [`addDataToMap`][6]
**Parameters**
-- `state` **[Object][9]** kepler.gl instance state, containing all subreducer state
-- `action` **[Object][9]**
- - `action.payload` **[Object][9]** `{datasets, options, config}`
- - `action.payload.datasets` **([Array][10]<[Object][9]> | [Object][9])** **\*required** datasets can be a dataset or an array of datasets
+- `state` **[Object][7]** kepler.gl instance state, containing all subreducer state
+- `action` **[Object][7]**
+ - `action.payload` **[Object][7]** `{datasets, options, config}`
+ - `action.payload.datasets` **([Array][8]<[Object][7]> | [Object][7])** **\*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` **[Object][9]** \-info of a dataset
- - `action.payload.datasets.info.id` **[string][11]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- - `action.payload.datasets.info.label` **[string][11]** A display name of this dataset
- - `action.payload.datasets.data` **[Object][9]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
- - `action.payload.datasets.data.fields` **[Array][10]<[Object][9]>** **\*required** Array of fields,
- - `action.payload.datasets.data.fields.name` **[string][11]** **\*required** Name of the field,
- - `action.payload.datasets.data.rows` **[Array][10]<[Array][10]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
- - `action.payload.options` **[Object][9]** option object `{centerMap: true}`
- - `action.payload.config` **[Object][9]** map config
-
-Returns **[Object][9]** nextState
-
-### updateVisDataUpdater
-
-Apply data and config to visState reducer
-
-- **Action**: [`updateVisData`][12]
-
-**Parameters**
-
-- `state` **[Object][9]** kepler.gl instance state, containing all subreducer state
-- `action` **[Object][9]**
- - `action.datasets` **([Array][10]<[Object][9]> | [Object][9])** **\*required** datasets can be a dataset or an array of datasets
- Each dataset object needs to have `info` and `data` property.
- - `action.datasets.info` **[Object][9]** \-info of a dataset
- - `action.datasets.info.id` **[string][11]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- - `action.datasets.info.label` **[string][11]** A display name of this dataset
- - `action.datasets.data` **[Object][9]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
- - `action.datasets.data.fields` **[Array][10]<[Object][9]>** **\*required** Array of fields,
- - `action.datasets.data.fields.name` **[string][11]** **\*required** Name of the field,
- - `action.datasets.data.rows` **[Array][10]<[Array][10]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
- - `action.options` **[Object][9]**
- - `action.options.centerMap` **[Boolean][13]**
- - `action.options.readOnly` **[Boolean][13]**
- - `action.config` **[Object][9]**
-
-Returns **[Object][9]** nextState
+ - `action.payload.datasets.info` **[Object][7]** \-info of a dataset
+ - `action.payload.datasets.info.id` **[string][9]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ - `action.payload.datasets.info.label` **[string][9]** A display name of this dataset
+ - `action.payload.datasets.data` **[Object][7]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ - `action.payload.datasets.data.fields` **[Array][8]<[Object][7]>** **\*required** Array of fields,
+ - `action.payload.datasets.data.fields.name` **[string][9]** **\*required** Name of the field,
+ - `action.payload.datasets.data.rows` **[Array][8]<[Array][8]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
+ - `action.payload.options` **[Object][7]** option object `{centerMap: true}`
+ - `action.payload.config` **[Object][7]** map config
+
+Returns **[Object][7]** nextState
[1]: #combinedupdaters
@@ -109,20 +82,12 @@ Returns **[Object][9]** nextState
[4]: #parameters
-[5]: #updatevisdataupdater
-
-[6]: #parameters-1
-
-[7]: ../advanced-usage/using-updaters.md
-
-[8]: ../actions/actions.md#adddatatomap
-
-[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
+[5]: ../advanced-usage/using-updaters.md
-[10]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
+[6]: ../actions/actions.md#adddatatomap
-[11]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
+[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
-[12]: ../actions/actions.md#updatevisdata
+[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
-[13]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
+[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
diff --git a/docs/api-reference/reducers/map-state.md b/docs/api-reference/reducers/map-state.md
index 69532fcb3..2ce9ccf1c 100644
--- a/docs/api-reference/reducers/map-state.md
+++ b/docs/api-reference/reducers/map-state.md
@@ -6,14 +6,15 @@
- [fitBoundsUpdater][3]
- [INITIAL_MAP_STATE][5]
- [receiveMapConfigUpdater][7]
- - [togglePerspectiveUpdater][9]
- - [toggleSplitMapUpdater][11]
- - [updateMapUpdater][13]
+ - [resetMapConfigUpdater][9]
+ - [togglePerspectiveUpdater][11]
+ - [toggleSplitMapUpdater][13]
+ - [updateMapUpdater][15]
## mapStateUpdaters
Updaters for `mapState` reducer. Can be used in your root reducer to directly modify kepler.gl's state.
-Read more about [Using updaters][15]
+Read more about [Using updaters][17]
**Examples**
@@ -52,15 +53,15 @@ export default composedReducer;
Fit map viewport to bounds
-- **Action**: [`fitBounds`][16]
+- **Action**: [`fitBounds`][18]
**Parameters**
-- `state` **[Object][17]**
-- `action` **[Object][17]**
- - `action.payload` **[Array][18]<[number][19]>** bounds as `[lngMin, latMin, lngMax, latMax]`
+- `state` **[Object][19]**
+- `action` **[Object][19]**
+ - `action.payload` **[Array][20]<[number][21]>** bounds as `[lngMin, latMin, lngMax, latMax]`
-Returns **[Object][17]** nextState
+Returns **[Object][19]** nextState
### INITIAL_MAP_STATE
@@ -68,67 +69,82 @@ Default initial `mapState`
#### Properties
-- `pitch` **[number][19]** Default: `0`
-- `bearing` **[number][19]** Default: `0`
-- `latitude` **[number][19]** Default: `37.75043`
-- `longitude` **[number][19]** Default: `-122.34679`
-- `zoom` **[number][19]** Default: `9`
-- `dragRotate` **[boolean][20]** Default: `false`
-- `width` **[number][19]** Default: `800`
-- `height` **[number][19]** Default: `800`
-- `isSplit` **[boolean][20]** Default: `false`
+- `pitch` **[number][21]** Default: `0`
+- `bearing` **[number][21]** Default: `0`
+- `latitude` **[number][21]** Default: `37.75043`
+- `longitude` **[number][21]** Default: `-122.34679`
+- `zoom` **[number][21]** Default: `9`
+- `dragRotate` **[boolean][22]** Default: `false`
+- `width` **[number][21]** Default: `800`
+- `height` **[number][21]** Default: `800`
+- `isSplit` **[boolean][22]** Default: `false`
### receiveMapConfigUpdater
Update `mapState` to propagate a new config
-- **Action**: [`receiveMapConfig`][21]
+- **Action**: [`receiveMapConfig`][23]
**Parameters**
-- `state` **[Object][17]**
-- `action` **[Object][17]**
- - `action.payload` **[Object][17]** saved map config
+- `state` **[Object][19]**
+- `action` **[Object][19]**
+ - `action.payload` **[Object][19]** saved map config
+ - `action.payload.config` (optional, default `{}`)
+ - `action.payload.options` (optional, default `{}`)
+ - `action.payload.bounds` (optional, default `null`)
-Returns **[Object][17]** nextState
+Returns **[Object][19]** nextState
+
+### resetMapConfigUpdater
+
+reset mapState to initial State
+
+- **Action**: [`resetMapConfig`][24]
+
+**Parameters**
+
+- `state` **[Object][19]** `mapState`
+
+Returns **[Object][19]** nextState
### togglePerspectiveUpdater
Toggle between 3d and 2d map.
-- **Action**: [`togglePerspective`][22]
+- **Action**: [`togglePerspective`][25]
**Parameters**
-- `state` **[Object][17]**
+- `state` **[Object][19]**
-Returns **[Object][17]** nextState
+Returns **[Object][19]** nextState
### toggleSplitMapUpdater
Toggle between one or split maps
-- **Action**: [`toggleSplitMap`][23]
+- **Action**: [`toggleSplitMap`][26]
**Parameters**
-- `state` **[Object][17]**
+- `state` **[Object][19]**
-Returns **[Object][17]** nextState
+Returns **[Object][19]** nextState
### updateMapUpdater
Update map viewport
-- **Action**: [`updateMap`][24]
+- **Action**: [`updateMap`][27]
**Parameters**
-- `state` **[Object][17]**
-- `action` **[Object][17]**
- - `action.payload` **[Object][17]** viewport
+- `state` **[Object][19]**
+- `action` **[Object][19]**
+ - `action.payload` **[Object][19]** viewport
-Returns **[Object][17]** nextState
+Returns **[Object][19]** nextState
[1]: #mapstateupdaters
@@ -146,34 +162,40 @@ Returns **[Object][17]** nextState
[8]: #parameters-1
-[9]: #toggleperspectiveupdater
+[9]: #resetmapconfigupdater
[10]: #parameters-2
-[11]: #togglesplitmapupdater
+[11]: #toggleperspectiveupdater
[12]: #parameters-3
-[13]: #updatemapupdater
+[13]: #togglesplitmapupdater
[14]: #parameters-4
-[15]: ../advanced-usage/using-updaters.md
+[15]: #updatemapupdater
+
+[16]: #parameters-5
+
+[17]: ../advanced-usage/using-updaters.md
+
+[18]: ../actions/actions.md#fitbounds
-[16]: ../actions/actions.md#fitbounds
+[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
-[17]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
+[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
-[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
+[21]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
-[19]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
+[22]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
-[20]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
+[23]: ../actions/actions.md#receivemapconfig
-[21]: ../actions/actions.md#receivemapconfig
+[24]: ../actions/actions.md#resetmapconfig
-[22]: ../actions/actions.md#toggleperspective
+[25]: ../actions/actions.md#toggleperspective
-[23]: ../actions/actions.md#togglesplitmap
+[26]: ../actions/actions.md#togglesplitmap
-[24]: ../actions/actions.md#updatemap
+[27]: ../actions/actions.md#updatemap
diff --git a/docs/api-reference/reducers/map-style.md b/docs/api-reference/reducers/map-style.md
index 84d6cce70..4a3321f01 100644
--- a/docs/api-reference/reducers/map-style.md
+++ b/docs/api-reference/reducers/map-style.md
@@ -61,14 +61,16 @@ Default initial `mapStyle`
- `styleType` **[string][22]** Default: `'dark'`
- `visibleLayerGroups` **[Object][23]** Default: `{}`
- `topLayerGroups` **[Object][23]** Default: `{}`
-- `mapStyles` **[Object][23]** mapping from style key to style objct
+- `mapStyles` **[Object][23]** mapping from style key to style object
- `mapboxApiAccessToken` **[string][22]** Default: `null`
- `inputStyle` **[Object][23]** Default: `{}`
- `threeDBuildingColor` **[Array][24]** Default: `[r, g, b]`
### initMapStyleUpdater
-Propagate `mapStyle` reducer with `mapboxApiAccessToken`
+Propagate `mapStyle` reducer with `mapboxApiAccessToken` and `mapStylesReplaceDefault`.
+if mapStylesReplaceDefault is true mapStyles is emptied; loadMapStylesUpdater() will
+populate mapStyles.
- **Action**: [`keplerGlInit`][25]
diff --git a/docs/api-reference/reducers/vis-state.md b/docs/api-reference/reducers/vis-state.md
index b14441e64..a6c2d37f1 100644
--- a/docs/api-reference/reducers/vis-state.md
+++ b/docs/api-reference/reducers/vis-state.md
@@ -21,22 +21,21 @@
- [removeFilterUpdater][33]
- [removeLayerUpdater][35]
- [reorderLayerUpdater][37]
- - [resetMapConfigVisStateUpdater][39]
+ - [resetMapConfigUpdater][39]
- [setFilterPlotUpdater][41]
- [setFilterUpdater][43]
- - [setVisibleLayersForMapUpdater][45]
- - [showDatasetTableUpdater][47]
- - [toggleFilterAnimationUpdater][49]
- - [toggleLayerForMapUpdater][51]
- - [toggleSplitMapUpdater][53]
- - [updateAnimationSpeedUpdater][55]
- - [updateLayerBlendingUpdater][57]
- - [updateVisDataUpdater][59]
+ - [showDatasetTableUpdater][45]
+ - [toggleFilterAnimationUpdater][47]
+ - [toggleLayerForMapUpdater][49]
+ - [toggleSplitMapUpdater][51]
+ - [updateAnimationSpeedUpdater][53]
+ - [updateLayerBlendingUpdater][55]
+ - [updateVisDataUpdater][57]
## visStateUpdaters
Updaters for `visState` reducer. Can be used in your root reducer to directly modify kepler.gl's state.
-Read more about [Using updaters][61]
+Read more about [Using updaters][59]
**Examples**
@@ -75,434 +74,423 @@ export default composedReducer;
Add a new filter
-- **Action**: [`addFilter`][62]
+- **Action**: [`addFilter`][60]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.dataId` **[string][64]** dataset `id` this new filter is associated with
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.dataId` **[string][62]** dataset `id` this new filter is associated with
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### addLayerUpdater
Add a new layer
-- **Action**: [`addLayer`][65]
+- **Action**: [`addLayer`][63]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.props` **[Object][63]** new layer props
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.props` **[Object][61]** new layer props
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### enlargeFilterUpdater
Show larger time filter at bottom for time playback (apply to time filter only)
-- **Action**: [`enlargeFilter`][66]
+- **Action**: [`enlargeFilter`][64]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** index of filter to enlarge
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** index of filter to enlarge
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### INITIAL_VIS_STATE
Default initial `visState`
-Type: [Object][63]
+Type: [Object][61]
#### Properties
-- `layers` **[Array][68]**
-- `layerData` **[Array][68]**
-- `layerToBeMerged` **[Array][68]**
-- `layerOrder` **[Array][68]**
-- `filters` **[Array][68]**
-- `filterToBeMerged` **[Array][68]**
-- `datasets` **[Array][68]**
-- `editingDataset` **[string][64]**
-- `interactionConfig` **[Object][63]**
-- `interactionToBeMerged` **[Object][63]**
-- `layerBlending` **[string][64]**
-- `hoverInfo` **[Object][63]**
-- `clicked` **[Object][63]**
-- `fileLoading` **[boolean][69]**
+- `layers` **[Array][66]**
+- `layerData` **[Array][66]**
+- `layerToBeMerged` **[Array][66]**
+- `layerOrder` **[Array][66]**
+- `filters` **[Array][66]**
+- `filterToBeMerged` **[Array][66]**
+- `datasets` **[Array][66]**
+- `editingDataset` **[string][62]**
+- `interactionConfig` **[Object][61]**
+- `interactionToBeMerged` **[Object][61]**
+- `layerBlending` **[string][62]**
+- `hoverInfo` **[Object][61]**
+- `clicked` **[Object][61]**
+- `fileLoading` **[boolean][67]**
- `fileLoadingErr` **any**
-- `splitMaps` **[Array][68]** a list of objects of layer availabilities and visibilities for each map
+- `splitMaps` **[Array][66]** a list of objects of layer availabilities and visibilities for each map
### interactionConfigChangeUpdater
Update `interactionConfig`
-- **Action**: [`interactionConfigChange`][70]
+- **Action**: [`interactionConfigChange`][68]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.config` **[Object][63]** new config as key value map: `{tooltip: {enabled: true}}`
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.config` **[Object][61]** new config as key value map: `{tooltip: {enabled: true}}`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### layerClickUpdater
Trigger layer click event with clicked object
-- **Action**: [`onLayerClick`][71]
+- **Action**: [`onLayerClick`][69]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.info` **[Object][63]** Object clicked, returned by deck.gl
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.info` **[Object][61]** Object clicked, returned by deck.gl
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### layerHoverUpdater
Trigger layer hover event with hovered object
-- **Action**: [`onLayerHover`][72]
+- **Action**: [`onLayerHover`][70]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.info` **[Object][63]** Object hovered, returned by deck.gl
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.info` **[Object][61]** Object hovered, returned by deck.gl
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### layerTypeChangeUpdater
Update layer type. Previews layer config will be copied if applicable.
-- **Action**: [`layerTypeChange`][73]
+- **Action**: [`layerTypeChange`][71]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.oldLayer` **[Object][63]** layer to be updated
- - `action.newType` **[string][64]** new type
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.oldLayer` **[Object][61]** layer to be updated
+ - `action.newType` **[string][62]** new type
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### layerVisConfigChangeUpdater
Update layer `visConfig`
-- **Action**: [`layerVisConfigChange`][74]
+- **Action**: [`layerVisConfigChange`][72]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.oldLayer` **[Object][63]** layer to be updated
- - `action.newVisConfig` **[Object][63]** new visConfig as a key value map: e.g. `{opacity: 0.8}`
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.oldLayer` **[Object][61]** layer to be updated
+ - `action.newVisConfig` **[Object][61]** new visConfig as a key value map: e.g. `{opacity: 0.8}`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### layerVisualChannelChangeUpdater
Update layer visual channel
-- **Action**: [`layerVisualChannelConfigChange`][75]
+- **Action**: [`layerVisualChannelConfigChange`][73]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.oldLayer` **[Object][63]** layer to be updated
- - `action.newConfig` **[Object][63]** new visual channel config
- - `action.channel` **[string][64]** channel to be updated
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.oldLayer` **[Object][61]** layer to be updated
+ - `action.newConfig` **[Object][61]** new visual channel config
+ - `action.channel` **[string][62]** channel to be updated
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### loadFilesErrUpdater
Trigger loading file error
-- **Action**: [`loadFilesErr`][76]
+- **Action**: [`loadFilesErr`][74]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
- `action.error` **any**
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### loadFilesUpdater
Trigger file loading dispatch `addDataToMap` if succeed, or `loadFilesErr` if failed
-- **Action**: [`loadFiles`][77]
+- **Action**: [`loadFiles`][75]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.files` **[Array][68]<[Object][63]>** array of fileblob
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.files` **[Array][66]<[Object][61]>** array of fileblob
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### mapClickUpdater
Trigger map click event, unselect clicked object
-- **Action**: [`onMapClick`][78]
+- **Action**: [`onMapClick`][76]
**Parameters**
-- `state` **[Object][63]** `visState`
+- `state` **[Object][61]** `visState`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### receiveMapConfigUpdater
Propagate `visState` reducer with a new configuration. Current config will be override.
-- **Action**: [`receiveMapConfig`][79]
+- **Action**: [`receiveMapConfig`][77]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.payload` **[Object][63]** map config to be propagated
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.payload` **[Object][61]** map config to be propagated
+ - `action.payload.config` **[Object][61]** map config to be propagated
+ - `action.payload.option` **[Object][61]** {keepExistingConfig: true | false}
+ - `action.payload.config` (optional, default `{}`)
+ - `action.payload.options` (optional, default `{}`)
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### removeDatasetUpdater
Remove a dataset and all layers, filters, tooltip configs that based on it
-- **Action**: [`removeDataset`][80]
+- **Action**: [`removeDataset`][78]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.key` **[string][64]** dataset id
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.key` **[string][62]** dataset id
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### removeFilterUpdater
Remove a filter
-- **Action**: [`removeFilter`][81]
+- **Action**: [`removeFilter`][79]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** index of filter to b e removed
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** index of filter to b e removed
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### removeLayerUpdater
remove layer
-- **Action**: [`removeLayer`][82]
+- **Action**: [`removeLayer`][80]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** index of layer to b e removed
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** index of layer to b e removed
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### reorderLayerUpdater
Reorder layer
-- **Action**: [`reorderLayer`][83]
+- **Action**: [`reorderLayer`][81]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.order` **[Array][68]<[Number][67]>** an array of layer indexes
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.order` **[Array][66]<[Number][65]>** an array of layer indexes
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
-### resetMapConfigVisStateUpdater
+### resetMapConfigUpdater
reset visState to initial State
-- **Action**: [`resetMapConfig`][84]
+- **Action**: [`resetMapConfig`][82]
**Parameters**
-- `state` **[Object][63]** `visState`
+- `state` **[Object][61]** `visState`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### setFilterPlotUpdater
Set the property of a filter plot
-- **Action**: [`setFilterPlot`][85]
+- **Action**: [`setFilterPlot`][83]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]**
- - `action.newProp` **[Object][63]** key value mapping of new prop `{yAxis: 'histogram'}`
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]**
+ - `action.newProp` **[Object][61]** key value mapping of new prop `{yAxis: 'histogram'}`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### setFilterUpdater
Update filter property
-- **Action**: [`setFilter`][86]
+- **Action**: [`setFilter`][84]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** `idx` of filter to be updated
- - `action.prop` **[string][64]** `prop` of filter, e,g, `dataId`, `name`, `value`
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** `idx` of filter to be updated
+ - `action.prop` **[string][62]** `prop` of filter, e,g, `dataId`, `name`, `value`
- `action.value` **any** new value
-Returns **[Object][63]** nextState
-
-### setVisibleLayersForMapUpdater
-
-Set layers to be visible in split map
-
-- **Action**: [`setVisibleLayersForMap`][87]
-
-**Parameters**
-
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
-- `mapIndex` **[Number][67]** index of the split map
-- `layerIds` **[Array][68]<[string][64]>** array of layer ids
-
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### showDatasetTableUpdater
Display dataset table in a modal
-- **Action**: [`showDatasetTable`][88]
+- **Action**: [`showDatasetTable`][85]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.dataId` **[string][64]** dataset id to show in table
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.dataId` **[string][62]** dataset id to show in table
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### toggleFilterAnimationUpdater
Start and end filter animation
-- **Action**: [`toggleAnimation`][89]
+- **Action**: [`toggleAnimation`][86]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** idx of filter
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** idx of filter
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### toggleLayerForMapUpdater
Toggle visibility of a layer in a split map
-- **Action**: [`toggleLayerForMap`][90]
+- **Action**: [`toggleLayerForMap`][87]
**Parameters**
-- `state` **[Object][63]**
-- `action` **[Object][63]**
- - `action.mapIndex` **[Number][67]** index of the split map
- - `action.layerId` **[string][64]** id of the layer
+- `state` **[Object][61]**
+- `action` **[Object][61]**
+ - `action.mapIndex` **[Number][65]** index of the split map
+ - `action.layerId` **[string][62]** id of the layer
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### toggleSplitMapUpdater
Toggle visibility of a layer for a split map
-- **Action**: [`toggleSplitMap`][91]
+- **Action**: [`toggleSplitMap`][88]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.payload` **([Number][67] \| [undefined][92])** index of the split map
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.payload` **([Number][65] \| [undefined][89])** index of the split map
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### updateAnimationSpeedUpdater
Change filter animation speed
-- **Action**: [`updateAnimationSpeed`][93]
+- **Action**: [`updateAnimationSpeed`][90]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.idx` **[Number][67]** `idx` of filter
- - `action.speed` **[Number][67]** `speed` to change it to. `speed` is a multiplier
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.idx` **[Number][65]** `idx` of filter
+ - `action.speed` **[Number][65]** `speed` to change it to. `speed` is a multiplier
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### updateLayerBlendingUpdater
update layer blending mode
-- **Action**: [`updateLayerBlending`][94]
+- **Action**: [`updateLayerBlending`][91]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.mode` **[string][64]** one of `additive`, `normal` and `subtractive`
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.mode` **[string][62]** one of `additive`, `normal` and `subtractive`
-Returns **[Object][63]** nextState
+Returns **[Object][61]** nextState
### updateVisDataUpdater
Add new dataset to `visState`, with option to load a map config along with the datasets
-- **Action**: [`updateVisData`][95]
+- **Action**: [`updateVisData`][92]
**Parameters**
-- `state` **[Object][63]** `visState`
-- `action` **[Object][63]** action
- - `action.datasets` **([Array][68]<[Object][63]> | [Object][63])** **\*required** datasets can be a dataset or an array of datasets
+- `state` **[Object][61]** `visState`
+- `action` **[Object][61]** action
+ - `action.datasets` **([Array][66]<[Object][61]> | [Object][61])** **\*required** datasets can be a dataset or an array of datasets
Each dataset object needs to have `info` and `data` property.
- - `action.datasets.info` **[Object][63]** \-info of a dataset
- - `action.datasets.info.id` **[string][64]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- - `action.datasets.info.label` **[string][64]** A display name of this dataset
- - `action.datasets.data` **[Object][63]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
- - `action.datasets.data.fields` **[Array][68]<[Object][63]>** **\*required** Array of fields,
- - `action.datasets.data.fields.name` **[string][64]** **\*required** Name of the field,
- - `action.datasets.data.rows` **[Array][68]<[Array][68]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
- - `action.options` **[Object][63]** option object `{centerMap: true}`
- - `action.config` **[Object][63]** map config
-
-Returns **[Object][63]** nextState
+ - `action.datasets.info` **[Object][61]** \-info of a dataset
+ - `action.datasets.info.id` **[string][62]** id of this dataset. If config is defined, `id` should matches the `dataId` in config.
+ - `action.datasets.info.label` **[string][62]** A display name of this dataset
+ - `action.datasets.data` **[Object][61]** **\*required** The data object, in a tabular format with 2 properties `fields` and `rows`
+ - `action.datasets.data.fields` **[Array][66]<[Object][61]>** **\*required** Array of fields,
+ - `action.datasets.data.fields.name` **[string][62]** **\*required** Name of the field,
+ - `action.datasets.data.rows` **[Array][66]<[Array][66]>** **\*required** Array of rows, in a tabular format with `fields` and `rows`
+ - `action.options` **[Object][61]** option object `{centerMap: true, keepExistingConfig: false}`
+ - `action.config` **[Object][61]** map config
+
+Returns **[Object][61]** nextState
[1]: #visstateupdaters
@@ -580,7 +568,7 @@ Returns **[Object][63]** nextState
[38]: #parameters-16
-[39]: #resetmapconfigvisstateupdater
+[39]: #resetmapconfigupdater
[40]: #parameters-17
@@ -592,104 +580,98 @@ Returns **[Object][63]** nextState
[44]: #parameters-19
-[45]: #setvisiblelayersformapupdater
+[45]: #showdatasettableupdater
[46]: #parameters-20
-[47]: #showdatasettableupdater
+[47]: #togglefilteranimationupdater
[48]: #parameters-21
-[49]: #togglefilteranimationupdater
+[49]: #togglelayerformapupdater
[50]: #parameters-22
-[51]: #togglelayerformapupdater
+[51]: #togglesplitmapupdater
[52]: #parameters-23
-[53]: #togglesplitmapupdater
+[53]: #updateanimationspeedupdater
[54]: #parameters-24
-[55]: #updateanimationspeedupdater
+[55]: #updatelayerblendingupdater
[56]: #parameters-25
-[57]: #updatelayerblendingupdater
+[57]: #updatevisdataupdater
[58]: #parameters-26
-[59]: #updatevisdataupdater
-
-[60]: #parameters-27
-
-[61]: ../advanced-usage/using-updaters.md
-
-[62]: ../actions/actions.md#addfilter
+[59]: ../advanced-usage/using-updaters.md
-[63]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
+[60]: ../actions/actions.md#addfilter
-[64]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
+[61]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
-[65]: ../actions/actions.md#addlayer
+[62]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
-[66]: ../actions/actions.md#enlargefilter
+[63]: ../actions/actions.md#addlayer
-[67]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
+[64]: ../actions/actions.md#enlargefilter
-[68]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
+[65]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
-[69]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
+[66]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
-[70]: ../actions/actions.md#interactionconfigchange
+[67]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
-[71]: ../actions/actions.md#onlayerclick
+[68]: ../actions/actions.md#interactionconfigchange
-[72]: ../actions/actions.md#onlayerhover
+[69]: ../actions/actions.md#onlayerclick
-[73]: ../actions/actions.md#layertypechange
+[70]: ../actions/actions.md#onlayerhover
-[74]: ../actions/actions.md#layervisconfigchange
+[71]: ../actions/actions.md#layertypechange
-[75]: ../actions/actions.md#layervisualchannelconfigchange
+[72]: ../actions/actions.md#layervisconfigchange
-[76]: ../actions/actions.md#loadfileserr
+[73]: ../actions/actions.md#layervisualchannelconfigchange
-[77]: ../actions/actions.md#loadfiles
+[74]: ../actions/actions.md#loadfileserr
-[78]: ../actions/actions.md#onmapclick
+[75]: ../actions/actions.md#loadfiles
-[79]: ../actions/actions.md#receivemapconfig
+[76]: ../actions/actions.md#onmapclick
-[80]: ../actions/actions.md#removedataset
+[77]: ../actions/actions.md#receivemapconfig
-[81]: ../actions/actions.md#removefilter
+[78]: ../actions/actions.md#removedataset
-[82]: ../actions/actions.md#removelayer
+[79]: ../actions/actions.md#removefilter
-[83]: ../actions/actions.md#reorderlayer
+[80]: ../actions/actions.md#removelayer
-[84]: ../actions/actions.md#resetmapconfig
+[81]: ../actions/actions.md#reorderlayer
-[85]: ../actions/actions.md#setfilterplot
+[82]: ../actions/actions.md#resetmapconfig
-[86]: ../actions/actions.md#setfilter
+[83]: ../actions/actions.md#setfilterplot
-[87]: ../actions/actions.md#setvisiblelayersformap
+[84]: ../actions/actions.md#setfilter
-[88]: ../actions/actions.md#showdatasettable
+[85]: ../actions/actions.md#showdatasettable
-[89]: ../actions/actions.md#toggleanimation
+[86]: ../actions/actions.md#toggleanimation
-[90]: ../actions/actions.md#togglelayerformap
+[87]: ../actions/actions.md#togglelayerformap
-[91]: ../actions/actions.md#togglesplitmap
+[88]: ../actions/actions.md#togglesplitmap
-[92]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
+[89]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
-[93]: ../actions/actions.md#updateanimationspeed
+[90]: ../actions/actions.md#updateanimationspeed
-[94]: ../actions/actions.md#updatelayerblending
+[91]: ../actions/actions.md#updatelayerblending
-[95]: ../actions/actions.md#updatevisdata
+[92]: ../actions/actions.md#updatevisdata
diff --git a/examples/demo-app/src/app.js b/examples/demo-app/src/app.js
index 5a84e06d2..59797a701 100644
--- a/examples/demo-app/src/app.js
+++ b/examples/demo-app/src/app.js
@@ -45,10 +45,11 @@ const KeplerGl = require('kepler.gl/components').injectComponents([
// Sample data
/* eslint-disable no-unused-vars */
-import sampleTripData from './data/sample-trip-data';
+import sampleTripData, {testCsvData} from './data/sample-trip-data';
import sampleGeojson from './data/sample-small-geojson';
import sampleGeojsonPoints from './data/sample-geojson-points';
-import sampleH3Data from './data/sample-hex-id-csv';
+import sampleGeojsonConfig from './data/sample-geojson-config';
+import sampleH3Data, {config as h3MapConfig} from './data/sample-hex-id-csv';
import sampleIconCsv, {config as savedMapConfig} from './data/sample-icon-csv';
import {addDataToMap, addNotification} from 'kepler.gl/actions';
import {processCsvData, processGeojson} from 'kepler.gl/processors';
@@ -161,8 +162,8 @@ class App extends Component {
_loadSampleData() {
this._loadTripData();
- // this._loadGeojsonData();
// this._loadIconData();
+ // this._loadGeojsonData();
// this._loadH3HexagonData();
}
@@ -220,14 +221,18 @@ class App extends Component {
addDataToMap({
datasets: [
{
- info: {label: 'Bart Stops Geo'},
+ info: {label: 'Bart Stops Geo', id: 'bart-stops-geo'},
data: processGeojson(sampleGeojsonPoints)
},
{
- info: {label: 'SF Zip Geo'},
+ info: {label: 'SF Zip Geo', id: 'sf-zip-geo'},
data: processGeojson(sampleGeojson)
}
- ]
+ ],
+ options: {
+ keepExistingConfig: true
+ },
+ config: sampleGeojsonConfig
})
);
}
@@ -244,7 +249,11 @@ class App extends Component {
},
data: processCsvData(sampleH3Data)
}
- ]
+ ],
+ config: h3MapConfig,
+ options: {
+ keepExistingConfig: true
+ }
})
);
}
diff --git a/examples/demo-app/src/data/sample-geojson-config.js b/examples/demo-app/src/data/sample-geojson-config.js
new file mode 100644
index 000000000..ae3f2d349
--- /dev/null
+++ b/examples/demo-app/src/data/sample-geojson-config.js
@@ -0,0 +1,202 @@
+// Copyright (c) 2019 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+const config = {
+ version: 'v1',
+ config: {
+ visState: {
+ filters: [],
+ layers: [
+ {
+ id: 'ze2p6id',
+ type: 'geojson',
+ config: {
+ dataId: 'bart-stops-geo',
+ label: 'Bart Stops Geo',
+ color: [151, 14, 45],
+ columns: {
+ geojson: '_geojson'
+ },
+ isVisible: true,
+ visConfig: {
+ opacity: 0.8,
+ thickness: 0.5,
+ strokeColor: [77, 193, 156],
+ colorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ strokeColorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ radius: 22.5,
+ sizeRange: [0, 10],
+ radiusRange: [0, 50],
+ heightRange: [0, 500],
+ elevationScale: 5,
+ stroked: true,
+ filled: true,
+ enable3d: false,
+ wireframe: false
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: null,
+ colorScale: 'quantile',
+ sizeField: null,
+ sizeScale: 'linear',
+ strokeColorField: null,
+ strokeColorScale: 'quantile',
+ heightField: null,
+ heightScale: 'linear',
+ radiusField: null,
+ radiusScale: 'linear'
+ }
+ },
+ {
+ id: 'ho3fgt9',
+ type: 'geojson',
+ config: {
+ dataId: 'sf-zip-geo',
+ label: 'SF Zip Geo',
+ color: [136, 87, 44],
+ columns: {
+ geojson: '_geojson'
+ },
+ isVisible: true,
+ visConfig: {
+ opacity: 0.8,
+ thickness: 0.5,
+ strokeColor: [255, 254, 213],
+ colorRange: {
+ name: 'UberPool 8',
+ type: 'diverging',
+ category: 'Uber',
+ colors: [
+ '#213E9A',
+ '#3C1FA7',
+ '#811CB5',
+ '#C318B0',
+ '#D01367',
+ '#DE0F0E',
+ '#EC7007',
+ '#F9E200'
+ ],
+ reversed: false
+ },
+ strokeColorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ radius: 10,
+ sizeRange: [0, 10],
+ radiusRange: [0, 50],
+ heightRange: [0, 500],
+ elevationScale: 5,
+ stroked: true,
+ filled: true,
+ enable3d: false,
+ wireframe: false
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: {
+ name: 'ID',
+ type: 'integer'
+ },
+ colorScale: 'quantile',
+ sizeField: null,
+ sizeScale: 'linear',
+ strokeColorField: null,
+ strokeColorScale: 'quantile',
+ heightField: null,
+ heightScale: 'linear',
+ radiusField: null,
+ radiusScale: 'linear'
+ }
+ }
+ ],
+ interactionConfig: {
+ tooltip: {
+ fieldsToShow: {
+ 'bart-stops-geo': ['name', 'code', 'address', 'entries', 'exits'],
+ 'sf-zip-geo': ['OBJECTID', 'ZIP_CODE', 'ID', 'name', 'STREETNAME']
+ },
+ enabled: true
+ },
+ brush: {
+ size: 0.5,
+ enabled: false
+ }
+ },
+ layerBlending: 'normal'
+ }
+ }
+};
+
+export default config;
diff --git a/examples/demo-app/src/data/sample-hex-id-csv.js b/examples/demo-app/src/data/sample-hex-id-csv.js
index 30ac2fe54..604f778c2 100644
--- a/examples/demo-app/src/data/sample-hex-id-csv.js
+++ b/examples/demo-app/src/data/sample-hex-id-csv.js
@@ -107,3 +107,113 @@ export default `hex_id,value
89283082d73ffff,1
8928309530bffff,1
8928309532bffff,1`;
+
+export const config = {
+ version: 'v1',
+ config: {
+ visState: {
+ filters: [],
+ layers: [
+ {
+ id: 'avlgol',
+ type: 'hexagonId',
+ config: {
+ dataId: 'h3-hex-id',
+ label: 'H3 Hexagon',
+ color: [241, 92, 23],
+ columns: {
+ hex_id: 'hex_id'
+ },
+ isVisible: true,
+ visConfig: {
+ opacity: 0.8,
+ colorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ coverage: 1,
+ sizeRange: [0, 500],
+ coverageRange: [0, 1],
+ elevationScale: 5
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: {
+ name: 'value',
+ type: 'integer'
+ },
+ colorScale: 'quantile',
+ sizeField: null,
+ sizeScale: 'linear',
+ coverageField: null,
+ coverageScale: 'linear'
+ }
+ }
+ ],
+ interactionConfig: {
+ tooltip: {
+ fieldsToShow: {
+ 'h3-hex-id': ['hex_id', 'value']
+ },
+ enabled: true
+ },
+ brush: {
+ size: 0.5,
+ enabled: false
+ }
+ },
+ layerBlending: 'normal',
+ splitMaps: [{
+ layers: {
+ avlgol: {
+ isAvailable: true,
+ isVisible: true
+ }
+ }
+ }, {
+ layers: {
+ avlgol: {
+ isAvailable: true,
+ isVisible: true
+ }
+ }
+ }]
+ },
+ mapStyle: {
+ styleType: 'dark',
+ topLayerGroups: {},
+ visibleLayerGroups: {
+ label: true,
+ road: true,
+ border: false,
+ building: true,
+ water: true,
+ land: true,
+ '3d building': false
+ },
+ mapStyles: {}
+ },
+ mapState: {
+ isSplit: true
+ }
+ }
+};
diff --git a/examples/demo-app/src/data/sample-trip-data.js b/examples/demo-app/src/data/sample-trip-data.js
index c2c1a88c0..8f747deb0 100644
--- a/examples/demo-app/src/data/sample-trip-data.js
+++ b/examples/demo-app/src/data/sample-trip-data.js
@@ -19,34 +19,57 @@
// THE SOFTWARE.
// Sample Taxi Trip Data
+export const testCsvData = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,gps_data.types,epoch,has_result,id,time,begintrip_ts_utc,begintrip_ts_local,date
+2016-09-17 00:09:55,29.9900937,31.2590542,driver_analytics,1472688000000,False,1,2016-09-23T00:00:00.000Z,2016-10-01 09:41:39+00:00,2016-10-01 09:41:39+00:00,2016-09-23
+2016-09-17 00:10:56,29.9927699,31.2461142,driver_analytics,1472688000000,False,2,2016-09-23T00:00:00.000Z,2016-10-01 09:46:37+00:00,2016-10-01 16:46:37+00:00,2016-09-23
+2016-09-17 00:11:56,29.9907261,31.2312742,driver_analytics,1472688000000,False,3,2016-09-23T00:00:00.000Z,,,2016-09-23
+2016-09-17 00:12:58,29.9870074,31.2175827,driver_analytics,1472688000000,False,4,2016-09-23T00:00:00.000Z,,,2016-09-23
+2016-09-17 00:14:00,29.9923041,31.2154899,driver_analytics,1472688000000,False,5,2016-09-23T00:00:00.000Z,2016-10-01 09:47:37+00:00,2016-10-01 16:47:37+00:00,
+2016-09-17 00:15:01,29.9968249,31.2149361,driver_analytics,1472688000000,False,12124,2016-09-23T05:00:00.000Z,,,
+2016-09-17 00:16:03,30.0037217,31.2164035,driver_analytics,1472688000000,False,222,2016-09-23T05:00:00.000Z,,,
+2016-09-17 00:17:05,30.0116207,31.2179346,driver_analytics,1472688000000,False,345,2016-09-23T00:00:00.000Z,,,2016-09-24
+2016-09-17 00:18:09,30.0208925,31.2179556,driver_analytics,1472708000000,False,,2016-09-23T00:00:00.000Z,,,2016-09-24
+2016-09-17 00:19:12,30.0218999,31.2178842,driver_analytics,1472708000000,False,,2016-09-23T06:00:00.000Z,,,2016-09-24
+2016-09-17 00:19:27,30.0229344,31.2179138,driver_analytics,1472708000000,False,,2016-09-23T05:00:00.000Z,,,2016-09-24
+2016-09-17 00:20:14,30.0264237,31.2179415,driver_analytics,1472708000000,False,,,,,2016-09-24
+2016-09-17 00:21:17,30.0292134,31.2181809,driver_analytics,1472754400000,False,,,,,2016-09-24
+2016-09-17 00:22:20,30.034391,31.2193991,driver_analytics,1472754400000,,,2016-09-23T06:00:00.000Z,,,
+2016-09-17 00:23:22,30.0352752,31.2181803,driver_analytics,1472754400000,,,2016-09-23T06:00:00.000Z,2016-10-01 10:01:54+00:00,2016-10-01 17:01:54+00:00,
+2016-09-17 00:24:24,30.0395918,31.2195902,driver_analytics,1472754400000,,1,2016-09-23T00:00:00.000Z,2016-10-01 09:53:04+00:00,2016-10-01 16:53:04+00:00,
+2016-09-17 00:25:28,30.0497387,31.2174421,driver_analytics,1472774400000,,,2016-09-23T07:00:00.000Z,2016-10-01 09:55:23+00:00,2016-10-01 16:55:23+00:00,
+2016-09-17 00:26:29,30.0538936,31.2165983,driver_analytics,1472774400000,,43,2016-09-23T07:00:00.000Z,2016-10-01 09:59:53+00:00,2016-10-01 16:59:53+00:00,2016-10-10
+2016-09-17 00:27:31,30.060911,31.2148748,driver_analytics,1472774400000,,4,2016-09-23T07:00:00.000Z,2016-10-01 09:57:11+00:00,2016-10-01 16:57:11+00:00,2016-10-10
+2016-09-17 00:28:35,30.060334,31.2212278,driver_analytics,1472774400000,,5,2016-09-23T07:00:00.000Z,2016-10-01 09:59:27+00:00,2016-10-01 16:59:27+00:00,2016-10-10
+2016-09-17 00:29:40,30.0554663,31.2288985,driver_analytics,1472774400000,True,,2016-09-23T07:00:00.000Z,2016-10-01 09:46:36+00:00,2016-10-01 16:46:36+00:00,2016-10-10
+2016-09-17 00:30:03,30.0614122,31.2187021,driver_gps,1472774400000,True,6,2016-09-23T08:00:00.000Z,2016-10-01 09:54:31+00:00,2016-10-01 16:54:31+00:00,2016-10-10
+2016-09-17 00:30:03,30.0612697,31.2191059,driver_gps,1472774400000,True,7,2016-09-23T08:00:00.000Z,2016-10-01 09:53:35+00:00,2016-10-01 16:53:35+00:00,2016-10-10
+2016-09-17 00:30:08,30.0610977,31.2194728,driver_gps,1472774400000,True,,2016-09-23T08:00:00.000Z,,,`;
+
export default {
fields: [
{
name: 'tpep_pickup_datetime',
format: 'YYYY-M-D H:m:s',
- tableFieldIndex: 1,
type: 'timestamp'
},
{
name: 'tpep_dropoff_datetime',
format: 'YYYY-M-D H:m:s',
- tableFieldIndex: 2,
type: 'timestamp'
},
{
name: 'passenger_count',
format: '',
- tableFieldIndex: 3,
type: 'integer'
},
- {name: 'trip_distance', format: '', tableFieldIndex: 4, type: 'real'},
- {name: 'pickup_longitude', format: '', tableFieldIndex: 5, type: 'real'},
- {name: 'pickup_latitude', format: '', tableFieldIndex: 6, type: 'real'},
- {name: 'dropoff_longitude', format: '', tableFieldIndex: 7, type: 'real'},
- {name: 'dropoff_latitude', format: '', tableFieldIndex: 8, type: 'real'},
- {name: 'fare_amount', format: '', tableFieldIndex: 9, type: 'real'},
- {name: 'is_completed', format: '', tableFieldIndex: 10, type: 'boolean'},
- {name: 'fare_type', format: '', tableFieldIndex: 11, type: 'string'}
+ {name: 'trip_distance', format: '', type: 'real'},
+ {name: 'pickup_longitude', format: '', type: 'real'},
+ {name: 'pickup_latitude', format: '', type: 'real'},
+ {name: 'dropoff_longitude', format: '', type: 'real'},
+ {name: 'dropoff_latitude', format: '', type: 'real'},
+ {name: 'fare_amount', format: '', type: 'real'},
+ {name: 'is_completed', format: '', type: 'boolean'},
+ {name: 'fare_type', format: '', type: 'string'}
],
rows: [
[
diff --git a/src/actions/actions.js b/src/actions/actions.js
index 9f930bf88..d3bf26959 100644
--- a/src/actions/actions.js
+++ b/src/actions/actions.js
@@ -45,9 +45,10 @@ import {createAction} from 'redux-actions';
*
* @param {Object} data.options
* @param {boolean} data.options.centerMap `default: true` if `centerMap` is set to `true` kepler.gl will
- * place the map view within the data points boundaries
+ * place the map view within the data points boundaries. `options.centerMap` will override `config.mapState` if passed in.
* @param {boolean} data.options.readOnly `default: false` if `readOnly` is set to `true`
* the left setting panel will be hidden
+ * @param {boolean} data.options.keepExistingConfig whether to keep exiting map data and associated layer filter interaction config `default: false`.
* @param {Object} data.config this object will contain the full kepler.gl instance configuration {mapState, mapStyle, visState}
* @public
* @example
@@ -93,7 +94,8 @@ import {createAction} from 'redux-actions';
* },
* option: {
* centerMap: true,
- * readOnly: false
+ * readOnly: false,
+ * keepExistingConfig: false
* },
* config: sampleConfig
* })
@@ -126,6 +128,12 @@ export const resetMapConfig = createAction(
* It will reset current configuration first then apply config to it.
* @memberof main
* @param {Object} config - ***required** The Config Object
+ * @param {Object} options - ***optional** The Option object
+ * @param {boolean} options.centerMap `default: true` if `centerMap` is set to `true` kepler.gl will
+ * place the map view within the data points boundaries
+ * @param {boolean} options.readOnly `default: false` if `readOnly` is set to `true`
+ * the left setting panel will be hidden
+ * @param {boolean} options.keepExistingConfig whether to keep exiting layer filter and interaction config `default: false`.
* @public
* @example
* import {receiveMapConfig} from 'kepler.gl/actions';
@@ -136,7 +144,7 @@ export const resetMapConfig = createAction(
*/
export const receiveMapConfig = createAction(
ActionTypes.RECEIVE_MAP_CONFIG,
- config => config
+ (config, options) => ({config, options})
);
/**
diff --git a/src/reducers/combined-updaters.js b/src/reducers/combined-updaters.js
index 3dcda3a37..e4953e736 100644
--- a/src/reducers/combined-updaters.js
+++ b/src/reducers/combined-updaters.js
@@ -18,13 +18,13 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-import {fitBoundsUpdater} from './map-state-updaters';
import {toggleModalUpdater} from './ui-state-updaters';
import {updateVisDataUpdater as visStateUpdateVisDataUpdater} from './vis-state-updaters';
import {receiveMapConfigUpdater as stateMapConfigUpdater} from './map-state-updaters';
import {receiveMapConfigUpdater as styleMapConfigUpdater} from './map-style-updaters';
import {findMapBounds} from 'utils/data-utils';
import KeplerGlSchema from 'schemas';
+import {isObject} from 'util';
// compose action to apply result multiple reducers, with the output of one
@@ -73,66 +73,12 @@ import KeplerGlSchema from 'schemas';
const combinedUpdaters = null;
/* eslint-enable no-unused-vars */
-/**
- * Apply data and config to visState reducer
- * @memberof combinedUpdaters
- * @param {Object} state kepler.gl instance state, containing all subreducer state
- * @param {Object} action
- * @param {Array<Object>|Object} action.datasets - ***required** datasets can be a dataset or an array of datasets
- * Each dataset object needs to have `info` and `data` property.
- * @param {Object} action.datasets.info -info of a dataset
- * @param {string} action.datasets.info.id - id of this dataset. If config is defined, `id` should matches the `dataId` in config.
- * @param {string} action.datasets.info.label - A display name of this dataset
- * @param {Object} action.datasets.data - ***required** The data object, in a tabular format with 2 properties `fields` and `rows`
- * @param {Array<Object>} action.datasets.data.fields - ***required** Array of fields,
- * @param {string} action.datasets.data.fields.name - ***required** Name of the field,
- * @param {Array<Array>} action.datasets.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
- * @param {Object} action.options
- * @param {Boolean} action.options.centerMap
- * @param {Boolean} action.options.readOnly
- * @param {Object} action.config
- * @returns {Object} nextState
- * @public
- */
-export const updateVisDataUpdater = (state, action) => {
- // keep a copy of oldLayers
- const oldLayers = state.visState.layers;
-
- const visState = visStateUpdateVisDataUpdater(state.visState, action);
-
- const defaultOptions = {
- centerMap: true
- };
-
- const options = {
- ...defaultOptions,
- ...action.options
- };
-
- let bounds;
- if (options.centerMap) {
- // find map bounds for new layers
- const newLayers = visState.layers.filter(nl => !oldLayers.find(ol => ol === nl));
- bounds = findMapBounds(newLayers);
- }
-
- return {
- ...state,
- visState,
- mapState: bounds
- ? fitBoundsUpdater(state.mapState, {
- payload: bounds
- })
- : state.mapState,
- uiState: {
- ...toggleModalUpdater(state.uiState, {payload: null}),
- ...(options.hasOwnProperty('readOnly') ? {readOnly: options.readOnly} : {})
- }
- };
+export const isValidConfig = config => isObject(config) && isObject(config.config) && config.version;
+export const defaultAddDataToMapOptions = {
+ readOnly: false,
+ centerMap: true,
+ keepExistingConfig: false
};
-
-export const updateVisDataComposed = updateVisDataUpdater;
-
/**
* Combine data and full configuration update in a single action
*
@@ -155,30 +101,66 @@ export const updateVisDataComposed = updateVisDataUpdater;
* @public
*/
export const addDataToMapUpdater = (state, {payload}) => {
+ const {datasets, config} = payload;
+
+ const options = {
+ ...defaultAddDataToMapOptions,
+ ...payload.options
+ };
- const {datasets, options, config} = payload;
let parsedConfig = config;
- if (config && config.config && config.version) {
+ if (isValidConfig(config)) {
// if passed in saved config
parsedConfig = KeplerGlSchema.parseSavedConfig(config)
}
+ const oldLayers = state.visState.layers;
+
// Update visState store
- let mergedState = updateVisDataComposed(state, {datasets, options, config: parsedConfig && parsedConfig.visState});
+ let mergedState = {
+ ...state,
+ visState: visStateUpdateVisDataUpdater(state.visState, {
+ datasets,
+ options,
+ config: parsedConfig
+ })
+ }
+
+ let bounds;
+ if (options.centerMap) {
+ // find map bounds for new layers
+ const newLayers = mergedState.visState.layers.filter(
+ nl => !oldLayers.find(ol => ol === nl)
+ );
+ bounds = findMapBounds(newLayers);
+ }
// Update mapState store
mergedState = {
...mergedState,
- mapState: stateMapConfigUpdater(mergedState.mapState, {payload: {mapState: parsedConfig && parsedConfig.mapState}})
+ mapState: stateMapConfigUpdater(mergedState.mapState, {
+ payload: {config: parsedConfig, options, bounds}
+ })
};
// Update mapStyle store
mergedState = {
...mergedState,
- mapStyle: styleMapConfigUpdater(mergedState.mapStyle, {payload: {mapStyle: parsedConfig && parsedConfig.mapStyle}})
+ mapStyle: styleMapConfigUpdater(mergedState.mapStyle, {
+ payload: {config: parsedConfig, options}
+ })
};
- return mergedState
+ // Update uiState
+ mergedState = {
+ ...mergedState,
+ uiState: {
+ ...toggleModalUpdater(mergedState.uiState, {payload: null}),
+ readOnly: options.readOnly
+ }
+ }
+
+ return mergedState;
};
export const addDataToMapComposed = addDataToMapUpdater;
diff --git a/src/reducers/map-state-updaters.js b/src/reducers/map-state-updaters.js
index 9133db907..40418fdb0 100644
--- a/src/reducers/map-state-updaters.js
+++ b/src/reducers/map-state-updaters.js
@@ -132,7 +132,7 @@ export const fitBoundsUpdater = (state, action) => {
* @returns {Object} nextState
* @public
*/
-export const togglePerspectiveUpdater = (state) => ({
+export const togglePerspectiveUpdater = state => ({
...state,
...{
pitch: state.dragRotate ? 0 : 50,
@@ -141,6 +141,19 @@ export const togglePerspectiveUpdater = (state) => ({
dragRotate: !state.dragRotate
});
+/**
+ * reset mapState to initial State
+ * @memberof mapStateUpdaters
+ * @param {Object} state `mapState`
+ * @returns {Object} nextState
+ * @public
+ */
+export const resetMapConfigUpdater = state => ({
+ ...INITIAL_MAP_STATE,
+ ...state.initialState,
+ initialState: state.initialState
+});
+
// consider case where you have a split map and user wants to reset
/**
* Update `mapState` to propagate a new config
@@ -151,14 +164,27 @@ export const togglePerspectiveUpdater = (state) => ({
* @returns {Object} nextState
* @public
*/
-export const receiveMapConfigUpdater = (state, action) => {
- const {isSplit = false} = action.payload.mapState || {};
+export const receiveMapConfigUpdater = (
+ state,
+ {payload: {config = {}, options = {}, bounds = null}}
+) => {
+ const {mapState} = config;
+
+ // merged received mapstate with previous state
+ let mergedState = {...state, ...mapState};
+
+ // if center map
+ // center map will override mapState config
+ if (options.centerMap && bounds) {
+ mergedState = fitBoundsUpdater(mergedState, {
+ payload: bounds
+ })
+ }
return {
- ...state,
- ...(action.payload.mapState || {}),
- isSplit,
- ...getMapDimForSplitMap(isSplit, state)
+ ...mergedState,
+ // update width if `isSplit` has changed
+ ...getMapDimForSplitMap(mergedState.isSplit, state)
};
};
@@ -169,14 +195,14 @@ export const receiveMapConfigUpdater = (state, action) => {
* @returns {Object} nextState
* @public
*/
-export const toggleSplitMapUpdater = (state) => ({
+export const toggleSplitMapUpdater = state => ({
...state,
isSplit: !state.isSplit,
...getMapDimForSplitMap(!state.isSplit, state)
});
// Helpers
-function getMapDimForSplitMap(isSplit, state) {
+export function getMapDimForSplitMap(isSplit, state) {
// cases:
// 1. state split: true - isSplit: true
// do nothing
@@ -186,13 +212,14 @@ function getMapDimForSplitMap(isSplit, state) {
return {};
}
- const width = state.isSplit && !isSplit ?
- // 3. state split: true - isSplit: false
- // double width
- state.width * 2
- // 4. state split: false - isSplit: true
- // split width
- : state.width / 2;
+ const width =
+ state.isSplit && !isSplit
+ ? // 3. state split: true - isSplit: false
+ // double width
+ state.width * 2
+ : // 4. state split: false - isSplit: true
+ // split width
+ state.width / 2;
return {
width
diff --git a/src/reducers/map-state.js b/src/reducers/map-state.js
index 18038ee47..883941985 100644
--- a/src/reducers/map-state.js
+++ b/src/reducers/map-state.js
@@ -31,6 +31,7 @@ const actionHandler = {
[ActionTypes.FIT_BOUNDS]: mapStateUpdaters.fitBoundsUpdater,
[ActionTypes.TOGGLE_PERSPECTIVE]: mapStateUpdaters.togglePerspectiveUpdater,
[ActionTypes.RECEIVE_MAP_CONFIG]: mapStateUpdaters.receiveMapConfigUpdater,
+ [ActionTypes.RESET_MAP_CONFIG]: mapStateUpdaters.resetMapConfigUpdater,
[ActionTypes.TOGGLE_SPLIT_MAP]: mapStateUpdaters.toggleSplitMapUpdater
};
diff --git a/src/reducers/map-style-updaters.js b/src/reducers/map-style-updaters.js
index ffa623e68..16ec286db 100644
--- a/src/reducers/map-style-updaters.js
+++ b/src/reducers/map-style-updaters.js
@@ -367,7 +367,9 @@ export const requestMapStylesUpdater = (state, {payload: mapStyles}) => {
* @param {Object} action.payload saved map config `{mapStyle, visState, mapState}`
* @returns {Object} nextState or `react-pam` tasks to load map style object
*/
-export const receiveMapConfigUpdater = (state, {payload: {mapStyle}}) => {
+export const receiveMapConfigUpdater = (state, {payload: {config = {}}}) => {
+ const {mapStyle} = config;
+
if (!mapStyle) {
return state;
}
diff --git a/src/reducers/vis-state-merger.js b/src/reducers/vis-state-merger.js
index 2a4c9fc5e..2c49e8992 100644
--- a/src/reducers/vis-state-merger.js
+++ b/src/reducers/vis-state-merger.js
@@ -29,6 +29,8 @@ import {
adjustValueToFilterDomain
} from 'utils/filter-utils';
+import {getInitialMapLayersForSplitMap} from 'utils/split-map-utils';
+
import {LAYER_BLENDINGS} from 'constants/default-settings';
/**
@@ -204,6 +206,39 @@ export function mergeInteractions(state, interactionToBeMerged) {
};
}
+/**
+ * Merge splitMaps config with current visStete.
+ * 1. if current map is split, but splitMap DOESNOT contain maps
+ * : don't merge anything
+ * 2. if current map is NOT split, but splitMaps contain maps
+ * : add to splitMaps, and add current layers to splitMaps
+ */
+export function mergeSplitMaps(state, splitMaps = []) {
+ const merged = [...state.splitMaps];
+ const unmerged = [];
+ splitMaps.forEach((sm, i) => {
+ Object.entries(sm.layers).forEach(([id, value]) => {
+ // check if layer exists
+ const pushTo = state.layers.find(l => l.id === id) ? merged : unmerged;
+
+ // create map panel if current map is not split
+ pushTo[i] = pushTo[i] || {
+ layers: pushTo === merged ? getInitialMapLayersForSplitMap(state.layers) : []
+ };
+ pushTo[i].layers = {
+ ...pushTo[i].layers,
+ [id]: value
+ };
+ });
+ });
+
+ return {
+ ...state,
+ splitMaps: merged,
+ splitMapsToBeMerged: unmerged
+ };
+}
+
/**
* Merge interactionConfig.tooltip with saved config,
* validate fieldsToShow
@@ -299,22 +334,32 @@ export function validateSavedLayerColumns(fields, savedCols, emptyCols) {
* @param {Object} savedTextLabel
* @return {Object} - validated textlabel
*/
-export function validateSavedTextLabel(fields, [layerTextLabel], savedTextLabel) {
- const savedTextLabels = Array.isArray(savedTextLabel) ?
- savedTextLabel : [savedTextLabel];
+export function validateSavedTextLabel(
+ fields,
+ [layerTextLabel],
+ savedTextLabel
+) {
+ const savedTextLabels = Array.isArray(savedTextLabel)
+ ? savedTextLabel
+ : [savedTextLabel];
// validate field
return savedTextLabels.map(textLabel => {
- const field = textLabel.field ? fields.find(fd =>
- Object.keys(textLabel.field).every(
- key => textLabel.field[key] === fd[key]
- )
- ) : null;
-
- return Object.keys(layerTextLabel).reduce((accu, key) => ({
- ...accu,
- [key]: key === 'field' ? field : (textLabel[key] || layerTextLabel[key])
- }), {});
+ const field = textLabel.field
+ ? fields.find(fd =>
+ Object.keys(textLabel.field).every(
+ key => textLabel.field[key] === fd[key]
+ )
+ )
+ : null;
+
+ return Object.keys(layerTextLabel).reduce(
+ (accu, key) => ({
+ ...accu,
+ [key]: key === 'field' ? field : textLabel[key] || layerTextLabel[key]
+ }),
+ {}
+ );
});
}
@@ -360,7 +405,11 @@ export function validateSavedVisualChannels(
* @param {Object} layerClasses
* @return {null | Object} - validated layer or null
*/
-export function validateLayerWithData({fields, id: dataId}, savedLayer, layerClasses) {
+export function validateLayerWithData(
+ {fields, id: dataId},
+ savedLayer,
+ layerClasses
+) {
const {type} = savedLayer;
// layer doesnt have a valid type
if (
@@ -399,11 +448,14 @@ export function validateLayerWithData({fields, id: dataId}, savedLayer, layerCla
savedLayer
);
- const textLabel = savedLayer.config.textLabel && newLayer.config.textLabel ? validateSavedTextLabel(
- fields,
- newLayer.config.textLabel,
- savedLayer.config.textLabel
- ) : newLayer.config.textLabel;
+ const textLabel =
+ savedLayer.config.textLabel && newLayer.config.textLabel
+ ? validateSavedTextLabel(
+ fields,
+ newLayer.config.textLabel,
+ savedLayer.config.textLabel
+ )
+ : newLayer.config.textLabel;
// copy visConfig over to emptyLayer to make sure it has all the props
const visConfig = newLayer.copyLayerConfig(
diff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.js
index d5aeb06d0..58233ff90 100644
--- a/src/reducers/vis-state-updaters.js
+++ b/src/reducers/vis-state-updaters.js
@@ -52,9 +52,16 @@ import {
mergeFilters,
mergeLayers,
mergeInteractions,
- mergeLayerBlending
+ mergeLayerBlending,
+ mergeSplitMaps
} from './vis-state-merger';
+import {
+ addNewLayersToSplitMap,
+ removeLayerFromSplitMaps,
+ computeSplitMapLayers
+} from 'utils/split-map-utils';
+
import {Layer, LayerClasses} from 'layers';
import {processFileToLoad} from '/utils/file-utils';
import {DEFAULT_TEXT_LABEL} from 'layers/layer-factory';
@@ -846,7 +853,7 @@ export const showDatasetTableUpdater = (state, action) => {
* @returns {Object} nextState
* @public
*/
-export const resetMapConfigVisStateUpdater = (state) => ({
+export const resetMapConfigUpdater = (state) => ({
...INITIAL_VIS_STATE,
...state.initialState,
initialState: state.initialState
@@ -858,11 +865,13 @@ export const resetMapConfigVisStateUpdater = (state) => ({
* @param {Object} state `visState`
* @param {Object} action action
* @param {Object} action.payload map config to be propagated
+ * @param {Object} action.payload.config map config to be propagated
+ * @param {Object} action.payload.option {keepExistingConfig: true | false}
* @returns {Object} nextState
* @public
*/
-export const receiveMapConfigUpdater = (state, action) => {
- if (!action.payload.visState) {
+export const receiveMapConfigUpdater = (state, {payload: {config = {}, options = {}}}) => {
+ if (!config.visState) {
return state;
}
@@ -872,19 +881,18 @@ export const receiveMapConfigUpdater = (state, action) => {
interactionConfig,
layerBlending,
splitMaps
- } = action.payload.visState;
+ } = config.visState;
- // always reset config when receive a new config
- const resetState = resetMapConfigVisStateUpdater(state);
- let mergedState = {
- ...resetState,
- splitMaps: splitMaps || [] // maps doesn't require any logic
- };
+ const {keepExistingConfig} = options;
+
+ // reset config if keepExistingConfig is falsy
+ let mergedState = !keepExistingConfig ? resetMapConfigUpdater(state) : state;
mergedState = mergeFilters(mergedState, filters);
mergedState = mergeLayers(mergedState, layers);
mergedState = mergeInteractions(mergedState, interactionConfig);
mergedState = mergeLayerBlending(mergedState, layerBlending);
+ mergedState = mergeSplitMaps(mergedState, splitMaps);
return mergedState;
};
@@ -1009,7 +1017,7 @@ export const toggleLayerForMapUpdater = (state, {mapIndex, layerId}) => {
* @param {Array<Object>} action.datasets.data.fields - ***required** Array of fields,
* @param {string} action.datasets.data.fields.name - ***required** Name of the field,
* @param {Array<Array>} action.datasets.data.rows - ***required** Array of rows, in a tabular format with `fields` and `rows`
- * @param {Object} action.options option object `{centerMap: true}`
+ * @param {Object} action.options option object `{centerMap: true, keepExistingConfig: false}`
* @param {Object} action.config map config
* @returns {Object} nextState
* @public
@@ -1017,17 +1025,12 @@ export const toggleLayerForMapUpdater = (state, {mapIndex, layerId}) => {
/* eslint-disable max-statements */
export const updateVisDataUpdater = (state, action) => {
// datasets can be a single data entries or an array of multiple data entries
+ const {config, options} = action;
+
const datasets = Array.isArray(action.datasets)
? action.datasets
: [action.datasets];
- if (action.config) {
- // apply config if passed from action
- state = receiveMapConfigUpdater(state, {
- payload: {visState: action.config}
- });
- }
-
const newDateEntries = datasets.reduce(
(accu, {info = {}, data}) => ({
...accu,
@@ -1040,10 +1043,15 @@ export const updateVisDataUpdater = (state, action) => {
return state;
}
+ // apply config if passed from action
+ const previousState = config ? receiveMapConfigUpdater(state, {
+ payload: {config, options}
+ }) : state;
+
const stateWithNewData = {
- ...state,
+ ...previousState,
datasets: {
- ...state.datasets,
+ ...previousState.datasets,
...newDateEntries
}
};
@@ -1052,13 +1060,16 @@ export const updateVisDataUpdater = (state, action) => {
const {
filterToBeMerged = [],
layerToBeMerged = [],
- interactionToBeMerged = {}
+ interactionToBeMerged = {},
+ splitMapsToBeMerged = []
} = stateWithNewData;
// merge state with saved filters
let mergedState = mergeFilters(stateWithNewData, filterToBeMerged);
// merge state with saved layers
mergedState = mergeLayers(mergedState, layerToBeMerged);
+ // merge state with saved splitMaps
+ mergedState = mergeSplitMaps(mergedState, splitMapsToBeMerged);
if (mergedState.layers.length === state.layers.length) {
// no layer merged, find defaults
@@ -1092,80 +1103,6 @@ export const updateVisDataUpdater = (state, action) => {
};
/* eslint-enable max-statements */
-/**
- * This method will compute the default maps layer settings
- * based on the current layers visibility
- * @param {Array<Object>} layers
- * @returns {Array<Object>} split map settings
- */
-function computeSplitMapLayers(layers) {
- const mapLayers = layers
- .filter(layer => layer.config.isVisible)
- .reduce(
- (newLayers, currentLayer) => ({
- ...newLayers,
- [currentLayer.id]: currentLayer.config.isVisible
- }),
- {}
- );
-
- return [
- {layers: mapLayers},
- {layers: cloneDeep(mapLayers)}
- ];
-}
-
-/**
- * Remove an existing layer from split map settings
- * @param {Object} splitMaps
- * @param {Object} layer
- * @returns {Object} Maps of custom layer objects
- */
-function removeLayerFromSplitMaps(splitMaps, layer) {
- if (!splitMaps.length) {
- return splitMaps;
- }
- return splitMaps.map(settings => {
- // eslint-disable-next-line no-unused-vars
- const {[layer.id]: _, ...newLayers} = settings.layers;
- return {
- ...settings,
- layers: newLayers
- };
- })
-}
-
-/**
- * Add new layers to both existing maps
- * @param {Object} splitMaps
- * @param {Object|Array<Object>} layers
- * @returns {Array<Object>} new splitMaps
- */
-function addNewLayersToSplitMap(splitMaps, layers) {
- const newLayers = Array.isArray(layers) ? layers : [layers];
-
- if (!splitMaps.length || !newLayers.length) {
- return splitMaps;
- }
-
- // add new layer to both maps,
- // don't override, if layer.id is already in splitMaps
- return splitMaps.map(settings => ({
- ...settings,
- layers: {
- ...settings.layers,
- ...newLayers.reduce(
- (accu, newLayer) =>
- [newLayer.id] in settings.layers || !newLayer.config.isVisible ? accu : {
- ...accu,
- [newLayer.id]: newLayer.config.isVisible
- },
- {}
- )
- }
- }));
-}
-
/**
* When a user clicks on the specific map closing icon
* the application will close the selected map
diff --git a/src/reducers/vis-state.js b/src/reducers/vis-state.js
index bd46f26da..af7bac272 100644
--- a/src/reducers/vis-state.js
+++ b/src/reducers/vis-state.js
@@ -67,7 +67,7 @@ const actionHandler = {
[ActionTypes.REORDER_LAYER]: visStateUpdaters.reorderLayerUpdater,
- [ActionTypes.RESET_MAP_CONFIG]: visStateUpdaters.resetMapConfigVisStateUpdater,
+ [ActionTypes.RESET_MAP_CONFIG]: visStateUpdaters.resetMapConfigUpdater,
[ActionTypes.SET_FILTER]: visStateUpdaters.setFilterUpdater,
diff --git a/src/utils/split-map-utils.js b/src/utils/split-map-utils.js
new file mode 100644
index 000000000..494d8f183
--- /dev/null
+++ b/src/utils/split-map-utils.js
@@ -0,0 +1,103 @@
+// Copyright (c) 2019 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+import cloneDeep from 'lodash.clonedeep';
+
+/**
+ * Add new layers to both existing maps
+ * @param {Object} splitMaps
+ * @param {Object|Array<Object>} layers
+ * @returns {Array<Object>} new splitMaps
+ */
+export function addNewLayersToSplitMap(splitMaps, layers) {
+ const newLayers = Array.isArray(layers) ? layers : [layers];
+
+ if (!splitMaps.length || !newLayers.length) {
+ return splitMaps;
+ }
+
+ // add new layer to both maps,
+ // don't override, if layer.id is already in splitMaps
+ return splitMaps.map(settings => ({
+ ...settings,
+ layers: {
+ ...settings.layers,
+ ...newLayers.reduce(
+ (accu, newLayer) =>
+ [newLayer.id] in settings.layers || !newLayer.config.isVisible
+ ? accu
+ : {
+ ...accu,
+ [newLayer.id]: newLayer.config.isVisible
+ },
+ {}
+ )
+ }
+ }));
+}
+
+/**
+ * Remove an existing layer from split map settings
+ * @param {Object} splitMaps
+ * @param {Object} layer
+ * @returns {Object} Maps of custom layer objects
+ */
+export function removeLayerFromSplitMaps(splitMaps, layer) {
+ if (!splitMaps.length) {
+ return splitMaps;
+ }
+ return splitMaps.map(settings => {
+ // eslint-disable-next-line no-unused-vars
+ const {[layer.id]: _, ...newLayers} = settings.layers;
+ return {
+ ...settings,
+ layers: newLayers
+ };
+ });
+}
+
+/**
+ * This method will compute the default maps layer settings
+ * based on the current layers visibility
+ * @param {Array<Object>} layers
+ * @returns {Array<Object>} layer visibility for each panel
+ */
+export function getInitialMapLayersForSplitMap(layers) {
+ return layers
+ .filter(layer => layer.config.isVisible)
+ .reduce(
+ (newLayers, currentLayer) => ({
+ ...newLayers,
+ [currentLayer.id]: currentLayer.config.isVisible
+ }),
+ {}
+ );
+}
+
+/**
+ * This method will get default splitMap settings based on existing layers
+ * @param {Array<Object>} layers
+ * @returns {Array<Object>} split map settings
+ */
+export function computeSplitMapLayers(layers) {
+ const mapLayers = getInitialMapLayersForSplitMap(layers);
+
+ return [{layers: mapLayers}, {layers: cloneDeep(mapLayers)}];
+}
diff --git a/test/fixtures/test-csv-data.js b/test/fixtures/test-csv-data.js
index f81fbb5f0..7b8c758e2 100644
--- a/test/fixtures/test-csv-data.js
+++ b/test/fixtures/test-csv-data.js
@@ -45,6 +45,224 @@ const data = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,gps_data.types,ep
2016-09-17 00:30:03,30.0612697,31.2191059,driver_gps,1472774400000,True,7,2016-09-23T08:00:00.000Z,2016-10-01 09:53:35+00:00,2016-10-01 16:53:35+00:00,2016-10-10
2016-09-17 00:30:08,30.0610977,31.2194728,driver_gps,1472774400000,True,,2016-09-23T08:00:00.000Z,,,`;
+const dataId = 'test_trip_data';
+
+export const config = {
+ version: 'v1',
+ config: {
+ visState: {
+ filters: [
+ {
+ dataId,
+ id: 'c75x65vlb',
+ name: 'gps_data.utc_timestamp',
+ type: 'timeRange',
+ value: [1474071773000, 1474072208000],
+ enlarged: true,
+ plotType: 'histogram',
+ yAxis: null
+ }
+ ],
+ layers: [
+ {
+ id: '3zucml7',
+ type: 'point',
+ config: {
+ dataId,
+ label: 'gps data',
+ color: [18, 147, 154],
+ columns: {
+ lat: 'gps_data.lat',
+ lng: 'gps_data.lng',
+ altitude: null
+ },
+ isVisible: true,
+ visConfig: {
+ radius: 39.2,
+ fixedRadius: false,
+ opacity: 0.74,
+ outline: true,
+ thickness: 2,
+ strokeColor: [254, 242, 26],
+ colorRange: {
+ name: 'UberPool 3',
+ type: 'diverging',
+ category: 'Uber',
+ colors: ['#213E9A', '#CA168E', '#F9E200'],
+ reversed: false
+ },
+ strokeColorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ radiusRange: [28.5, 194.7],
+ filled: true
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: {
+ name: 'gps_data.types',
+ type: 'string'
+ },
+ colorScale: 'ordinal',
+ strokeColorField: null,
+ strokeColorScale: 'quantile',
+ sizeField: {
+ name: 'id',
+ type: 'integer'
+ },
+ sizeScale: 'sqrt'
+ }
+ },
+ {
+ id: 'nob639j',
+ type: 'hexagon',
+ config: {
+ dataId,
+ label: 'hexbin',
+ color: [34, 63, 154],
+ columns: {
+ lat: 'gps_data.lat',
+ lng: 'gps_data.lng'
+ },
+ isVisible: true,
+ visConfig: {
+ opacity: 0.8,
+ worldUnitSize: 1,
+ resolution: 8,
+ colorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ coverage: 1,
+ sizeRange: [0, 500],
+ percentile: [0, 100],
+ elevationPercentile: [0, 100],
+ elevationScale: 5,
+ colorAggregation: 'count',
+ sizeAggregation: 'count',
+ enable3d: false
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: null,
+ colorScale: 'quantile',
+ sizeField: null,
+ sizeScale: 'linear'
+ }
+ }
+ ],
+ interactionConfig: {
+ tooltip: {
+ fieldsToShow: {
+ [dataId]: ['gps_data.types', 'has_result', 'id', 'time']
+ },
+ enabled: true
+ },
+ brush: {
+ size: 0.5,
+ enabled: false
+ }
+ },
+ layerBlending: 'normal',
+ splitMaps: [
+ {
+ layers: {
+ '3zucml7': {
+ isAvailable: true,
+ isVisible: true
+ },
+ nob639j: {
+ isAvailable: true,
+ isVisible: false
+ }
+ }
+ },
+ {
+ layers: {
+ '3zucml7': {
+ isAvailable: true,
+ isVisible: false
+ },
+ nob639j: {
+ isAvailable: true,
+ isVisible: true
+ }
+ }
+ }
+ ]
+ },
+ mapState: {
+ bearing: 24,
+ dragRotate: true,
+ latitude: 30.028974821846045,
+ longitude: 31.205476105912005,
+ pitch: 50,
+ zoom: 12.456401285586372,
+ isSplit: true
+ },
+ mapStyle: {
+ styleType: 'light',
+ topLayerGroups: {
+ road: true
+ },
+ visibleLayerGroups: {
+ label: false,
+ road: true,
+ border: false,
+ building: true,
+ water: true,
+ land: true,
+ '3d building': false
+ },
+ mapStyles: {}
+ }
+ }
+};
+
+export const sampleConfig = {
+ dataId,
+ config
+};
+
export const dataWithNulls = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,gps_data.types,epoch,has_result,id,time,begintrip_ts_utc,begintrip_ts_local,date
2016-09-17 00:09:55,29.9900937,31.2590542,driver_analytics,1472688000000,False,1,2016-09-23T00:00:00.000Z,2016-10-01 09:41:39+00:00,2016-10-01 09:41:39+00:00,2016-09-23
2016-09-17 00:10:56,29.9927699,31.2461142,driver_analytics,1472688000000,False,null,2016-09-23T00:00:00.000Z,2016-10-01 09:46:37+00:00,2016-10-01 16:46:37+00:00,2016-09-23
@@ -60,163 +278,177 @@ export const dataWithNulls = `gps_data.utc_timestamp,gps_data.lat,gps_data.lng,g
2016-09-17 00:20:14,30.0264237,31.2179415,driver_analytics,1472708000000,False,,,,,2016-09-24
2016-09-17 00:21:17,30.0292134,31.2181809,driver_analytics,1472754400000,False,,,,,2016-09-24`;
-export const parsedDataWithNulls = [[
- '2016-09-17 00:09:55',
- 29.9900937,
- 31.2590542,
- 'driver_analytics',
- 1472688000000,
- false,
- 1,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:41:39+00:00',
- '2016-10-01 09:41:39+00:00',
- '2016-09-23'
-], [
- '2016-09-17 00:10:56',
- 29.9927699,
- 31.2461142,
- 'driver_analytics',
- 1472688000000,
- false,
- null,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:46:37+00:00',
- '2016-10-01 16:46:37+00:00',
- '2016-09-23'
-], [
- '2016-09-17 00:11:56',
- 29.9907261,
- null,
- 'driver_analytics',
- 1472688000000,
- false,
- 3,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-23'
-], [
- '2016-09-17 00:12:58',
- 29.9870074,
- 31.2175827,
- 'driver_analytics',
- 1472688000000,
- false,
- 4,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-23'
-], [
- '2016-09-17 00:14:00',
- 29.9923041,
- 31.2154899,
- 'driver_analytics',
- 1472688000000,
- true,
- 5,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:47:37+00:00',
- '2016-10-01 16:47:37+00:00',
- null
-], [
- '2016-09-17 00:15:01',
- 29.9968249,
- 31.2149361,
- 'driver_analytics',
- 1472688000000,
- false,
- 12124,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- null
-], [
- '2016-09-17 00:16:03',
- null,
- 31.2164035,
- 'driver_analytics',
- 1472688000000,
- false,
- 222,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- null
-], [
- '2016-09-17 00:17:05',
- 30.0116207,
- 31.2179346,
- 'driver_analytics',
- 1472688000000,
- false,
- 345,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:18:09',
- 30.0208925,
- 31.2179556,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:19:12',
- 30.0218999,
- 31.2178842,
- 'driver_analytics',
- null,
- false,
- null,
- '2016-09-23T06:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:19:27',
- 30.0229344,
- 31.2179138,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:20:14',
- 30.0264237,
- 31.2179415,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- null,
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:21:17',
- 30.0292134,
- 31.2181809,
- 'driver_analytics',
- 1472754400000,
- false,
- null,
- null,
- null,
- null,
- '2016-09-24'
-]];
+export const parsedDataWithNulls = [
+ [
+ '2016-09-17 00:09:55',
+ 29.9900937,
+ 31.2590542,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 1,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:41:39+00:00',
+ '2016-10-01 09:41:39+00:00',
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:10:56',
+ 29.9927699,
+ 31.2461142,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ null,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:46:37+00:00',
+ '2016-10-01 16:46:37+00:00',
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:11:56',
+ 29.9907261,
+ null,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 3,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:12:58',
+ 29.9870074,
+ 31.2175827,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 4,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:14:00',
+ 29.9923041,
+ 31.2154899,
+ 'driver_analytics',
+ 1472688000000,
+ true,
+ 5,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:47:37+00:00',
+ '2016-10-01 16:47:37+00:00',
+ null
+ ],
+ [
+ '2016-09-17 00:15:01',
+ 29.9968249,
+ 31.2149361,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 12124,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ null
+ ],
+ [
+ '2016-09-17 00:16:03',
+ null,
+ 31.2164035,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 222,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ null
+ ],
+ [
+ '2016-09-17 00:17:05',
+ 30.0116207,
+ 31.2179346,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 345,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:18:09',
+ 30.0208925,
+ 31.2179556,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:19:12',
+ 30.0218999,
+ 31.2178842,
+ 'driver_analytics',
+ null,
+ false,
+ null,
+ '2016-09-23T06:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:19:27',
+ 30.0229344,
+ 31.2179138,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:20:14',
+ 30.0264237,
+ 31.2179415,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ null,
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:21:17',
+ 30.0292134,
+ 31.2181809,
+ 'driver_analytics',
+ 1472754400000,
+ false,
+ null,
+ null,
+ null,
+ null,
+ '2016-09-24'
+ ]
+];
export const wktCsv = `a_zip,simplified_shape_v2,simplified_shape,m_rate,c_zip_type,c_number
7014,"{""type"":""Polygon"",""coordinates"":[[[-74.158491,40.835947],[-74.157914,40.83902],[-74.148473,40.834522]]]}","POLYGON ((-74.158491 40.835947, -74.158491 40.835947))",7.5,C_Medium_High,29.07437458
@@ -225,384 +457,428 @@ export const wktCsv = `a_zip,simplified_shape_v2,simplified_shape,m_rate,c_zip_t
7029,"{""type"":""Polygon"",""coordinates"":[[[-74.165995,40.747969],[-74.165987,40.745199],[-74.165995,40.747969]]]}","POLYGON ((-74.165995 40.747969, -74.163788 40.739201, -74.165987 40.745199, -74.165995 40.747969))",11.8,C_Medium_High,39.13775443
7416,"{""type"":""MultiPolygon"",""coordinates"":[[[[-74.566993,41.087294],[-74.564908,41.089339],[-74.552353,41.091647],[-74.566993,41.087294]]],[[[-74.593264,41.088526],[-74.593264,41.088526]]]]}","MULTIPOLYGON (((-74.566993 41.087294, -74.564908 41.089339, -74.56559 41.090507, -74.557344 41.105958, -74.585763 41.083491, -74.593264 41.088526)))",10,A_Low_Rural,13.81679389`;
-export const testFields = [{
- type: 'timestamp',
- name: 'gps_data.utc_timestamp',
- format: 'YYYY-M-D H:m:s',
- tableFieldIndex: 1
-}, {
- type: 'real',
- name: 'gps_data.lat',
- format: '',
- tableFieldIndex: 2
-}, {
- type: 'real',
- name: 'gps_data.lng',
- format: '',
- tableFieldIndex: 3
-}, {
- type: 'string',
- name: 'gps_data.types',
- format: '',
- tableFieldIndex: 4
-}, {
- type: 'timestamp',
- name: 'epoch',
- format: 'X',
- tableFieldIndex: 5
-}, {
- type: 'boolean',
- name: 'has_result',
- format: '',
- tableFieldIndex: 6
-}, {
- type: 'integer',
- name: 'id',
- format: '',
- tableFieldIndex: 7
-}, {
- type: 'timestamp',
- name: 'time',
- format: 'YYYY-M-DTHH:mm:ss.SSSS',
- tableFieldIndex: 8
-}, {
- type: 'timestamp',
- name: 'begintrip_ts_utc',
- format: 'YYYY-M-D HH:mm:ssZZ',
- tableFieldIndex: 9
-}, {
- type: 'timestamp',
- name: 'begintrip_ts_local',
- format: 'YYYY-M-D HH:mm:ssZZ',
- tableFieldIndex: 10
-}, {
- type: 'date',
- name: 'date',
- format: 'YYYY-M-D',
- tableFieldIndex: 11
-}];
+export const testFields = [
+ {
+ type: 'timestamp',
+ name: 'gps_data.utc_timestamp',
+ format: 'YYYY-M-D H:m:s',
+ tableFieldIndex: 1
+ },
+ {
+ type: 'real',
+ name: 'gps_data.lat',
+ format: '',
+ tableFieldIndex: 2
+ },
+ {
+ type: 'real',
+ name: 'gps_data.lng',
+ format: '',
+ tableFieldIndex: 3
+ },
+ {
+ type: 'string',
+ name: 'gps_data.types',
+ format: '',
+ tableFieldIndex: 4
+ },
+ {
+ type: 'timestamp',
+ name: 'epoch',
+ format: 'X',
+ tableFieldIndex: 5
+ },
+ {
+ type: 'boolean',
+ name: 'has_result',
+ format: '',
+ tableFieldIndex: 6
+ },
+ {
+ type: 'integer',
+ name: 'id',
+ format: '',
+ tableFieldIndex: 7
+ },
+ {
+ type: 'timestamp',
+ name: 'time',
+ format: 'YYYY-M-DTHH:mm:ss.SSSS',
+ tableFieldIndex: 8
+ },
+ {
+ type: 'timestamp',
+ name: 'begintrip_ts_utc',
+ format: 'YYYY-M-D HH:mm:ssZZ',
+ tableFieldIndex: 9
+ },
+ {
+ type: 'timestamp',
+ name: 'begintrip_ts_local',
+ format: 'YYYY-M-D HH:mm:ssZZ',
+ tableFieldIndex: 10
+ },
+ {
+ type: 'date',
+ name: 'date',
+ format: 'YYYY-M-D',
+ tableFieldIndex: 11
+ }
+];
-export const wktCsvFields = [{
- type: 'integer',
- name: 'a_zip',
- format: '',
- tableFieldIndex: 1
-}, {
- type: 'geojson',
- name: 'simplified_shape_v2',
- format: '',
- tableFieldIndex: 2
-}, {
- type: 'geojson',
- name: 'simplified_shape',
- format: '',
- tableFieldIndex: 3
-}, {
- type: 'real',
- name: 'm_rate',
- format: '',
- tableFieldIndex: 4
-}, {
- type: 'string',
- name: 'c_zip_type',
- format: '',
- tableFieldIndex: 5
-}, {
- type: 'real',
- name: 'c_number',
- format: '',
- tableFieldIndex: 6
-}];
+export const wktCsvFields = [
+ {
+ type: 'integer',
+ name: 'a_zip',
+ format: '',
+ tableFieldIndex: 1
+ },
+ {
+ type: 'geojson',
+ name: 'simplified_shape_v2',
+ format: '',
+ tableFieldIndex: 2
+ },
+ {
+ type: 'geojson',
+ name: 'simplified_shape',
+ format: '',
+ tableFieldIndex: 3
+ },
+ {
+ type: 'real',
+ name: 'm_rate',
+ format: '',
+ tableFieldIndex: 4
+ },
+ {
+ type: 'string',
+ name: 'c_zip_type',
+ format: '',
+ tableFieldIndex: 5
+ },
+ {
+ type: 'real',
+ name: 'c_number',
+ format: '',
+ tableFieldIndex: 6
+ }
+];
-export const testAllData = [[
- '2016-09-17 00:09:55',
- 29.9900937,
- 31.2590542,
- 'driver_analytics',
- 1472688000000,
- false,
- 1,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:41:39+00:00',
- '2016-10-01 09:41:39+00:00',
- '2016-09-23'
-], [
- '2016-09-17 00:10:56',
- 29.9927699,
- 31.2461142,
- 'driver_analytics',
- 1472688000000,
- false,
- 2,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:46:37+00:00',
- '2016-10-01 16:46:37+00:00',
- '2016-09-23'
-], [
- '2016-09-17 00:11:56',
- 29.9907261,
- 31.2312742,
- 'driver_analytics',
- 1472688000000,
- false,
- 3,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-23'
-], [
- '2016-09-17 00:12:58',
- 29.9870074,
- 31.2175827,
- 'driver_analytics',
- 1472688000000,
- false,
- 4,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-23'
-], [
- '2016-09-17 00:14:00',
- 29.9923041,
- 31.2154899,
- 'driver_analytics',
- 1472688000000,
- false,
- 5,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:47:37+00:00',
- '2016-10-01 16:47:37+00:00',
- null
-], [
- '2016-09-17 00:15:01',
- 29.9968249,
- 31.2149361,
- 'driver_analytics',
- 1472688000000,
- false,
- 12124,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- null
-], [
- '2016-09-17 00:16:03',
- 30.0037217,
- 31.2164035,
- 'driver_analytics',
- 1472688000000,
- false,
- 222,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- null
-], [
- '2016-09-17 00:17:05',
- 30.0116207,
- 31.2179346,
- 'driver_analytics',
- 1472688000000,
- false,
- 345,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:18:09',
- 30.0208925,
- 31.2179556,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- '2016-09-23T00:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:19:12',
- 30.0218999,
- 31.2178842,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- '2016-09-23T06:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:19:27',
- 30.0229344,
- 31.2179138,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- '2016-09-23T05:00:00.000Z',
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:20:14',
- 30.0264237,
- 31.2179415,
- 'driver_analytics',
- 1472708000000,
- false,
- null,
- null,
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:21:17',
- 30.0292134,
- 31.2181809,
- 'driver_analytics',
- 1472754400000,
- false,
- null,
- null,
- null,
- null,
- '2016-09-24'
-], [
- '2016-09-17 00:22:20',
- 30.034391,
- 31.2193991,
- 'driver_analytics',
- 1472754400000,
- null,
- null,
- '2016-09-23T06:00:00.000Z',
- null,
- null,
- null
-], [
- '2016-09-17 00:23:22',
- 30.0352752,
- 31.2181803,
- 'driver_analytics',
- 1472754400000,
- null,
- null,
- '2016-09-23T06:00:00.000Z',
- '2016-10-01 10:01:54+00:00',
- '2016-10-01 17:01:54+00:00',
- null
-], [
- '2016-09-17 00:24:24',
- 30.0395918,
- 31.2195902,
- 'driver_analytics',
- 1472754400000,
- null,
- 1,
- '2016-09-23T00:00:00.000Z',
- '2016-10-01 09:53:04+00:00',
- '2016-10-01 16:53:04+00:00',
- null
-], [
- '2016-09-17 00:25:28',
- 30.0497387,
- 31.2174421,
- 'driver_analytics',
- 1472774400000,
- null,
- null,
- '2016-09-23T07:00:00.000Z',
- '2016-10-01 09:55:23+00:00',
- '2016-10-01 16:55:23+00:00',
- null
-], [
- '2016-09-17 00:26:29',
- 30.0538936,
- 31.2165983,
- 'driver_analytics',
- 1472774400000,
- null,
- 43,
- '2016-09-23T07:00:00.000Z',
- '2016-10-01 09:59:53+00:00',
- '2016-10-01 16:59:53+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:27:31',
- 30.060911,
- 31.2148748,
- 'driver_analytics',
- 1472774400000,
- null,
- 4,
- '2016-09-23T07:00:00.000Z',
- '2016-10-01 09:57:11+00:00',
- '2016-10-01 16:57:11+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:28:35',
- 30.060334,
- 31.2212278,
- 'driver_analytics',
- 1472774400000,
- null,
- 5,
- '2016-09-23T07:00:00.000Z',
- '2016-10-01 09:59:27+00:00',
- '2016-10-01 16:59:27+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:29:40',
- 30.0554663,
- 31.2288985,
- 'driver_analytics',
- 1472774400000,
- true,
- null,
- '2016-09-23T07:00:00.000Z',
- '2016-10-01 09:46:36+00:00',
- '2016-10-01 16:46:36+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:30:03',
- 30.0614122,
- 31.2187021,
- 'driver_gps',
- 1472774400000,
- true,
- 6,
- '2016-09-23T08:00:00.000Z',
- '2016-10-01 09:54:31+00:00',
- '2016-10-01 16:54:31+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:30:03',
- 30.0612697,
- 31.2191059,
- 'driver_gps',
- 1472774400000,
- true,
- 7,
- '2016-09-23T08:00:00.000Z',
- '2016-10-01 09:53:35+00:00',
- '2016-10-01 16:53:35+00:00',
- '2016-10-10'
-], [
- '2016-09-17 00:30:08',
- 30.0610977,
- 31.2194728,
- 'driver_gps',
- 1472774400000,
- true,
- null,
- '2016-09-23T08:00:00.000Z',
- null,
- null,
- null
-]];
+export const testAllData = [
+ [
+ '2016-09-17 00:09:55',
+ 29.9900937,
+ 31.2590542,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 1,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:41:39+00:00',
+ '2016-10-01 09:41:39+00:00',
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:10:56',
+ 29.9927699,
+ 31.2461142,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 2,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:46:37+00:00',
+ '2016-10-01 16:46:37+00:00',
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:11:56',
+ 29.9907261,
+ 31.2312742,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 3,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:12:58',
+ 29.9870074,
+ 31.2175827,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 4,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-23'
+ ],
+ [
+ '2016-09-17 00:14:00',
+ 29.9923041,
+ 31.2154899,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 5,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:47:37+00:00',
+ '2016-10-01 16:47:37+00:00',
+ null
+ ],
+ [
+ '2016-09-17 00:15:01',
+ 29.9968249,
+ 31.2149361,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 12124,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ null
+ ],
+ [
+ '2016-09-17 00:16:03',
+ 30.0037217,
+ 31.2164035,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 222,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ null
+ ],
+ [
+ '2016-09-17 00:17:05',
+ 30.0116207,
+ 31.2179346,
+ 'driver_analytics',
+ 1472688000000,
+ false,
+ 345,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:18:09',
+ 30.0208925,
+ 31.2179556,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ '2016-09-23T00:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:19:12',
+ 30.0218999,
+ 31.2178842,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ '2016-09-23T06:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:19:27',
+ 30.0229344,
+ 31.2179138,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ '2016-09-23T05:00:00.000Z',
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:20:14',
+ 30.0264237,
+ 31.2179415,
+ 'driver_analytics',
+ 1472708000000,
+ false,
+ null,
+ null,
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:21:17',
+ 30.0292134,
+ 31.2181809,
+ 'driver_analytics',
+ 1472754400000,
+ false,
+ null,
+ null,
+ null,
+ null,
+ '2016-09-24'
+ ],
+ [
+ '2016-09-17 00:22:20',
+ 30.034391,
+ 31.2193991,
+ 'driver_analytics',
+ 1472754400000,
+ null,
+ null,
+ '2016-09-23T06:00:00.000Z',
+ null,
+ null,
+ null
+ ],
+ [
+ '2016-09-17 00:23:22',
+ 30.0352752,
+ 31.2181803,
+ 'driver_analytics',
+ 1472754400000,
+ null,
+ null,
+ '2016-09-23T06:00:00.000Z',
+ '2016-10-01 10:01:54+00:00',
+ '2016-10-01 17:01:54+00:00',
+ null
+ ],
+ [
+ '2016-09-17 00:24:24',
+ 30.0395918,
+ 31.2195902,
+ 'driver_analytics',
+ 1472754400000,
+ null,
+ 1,
+ '2016-09-23T00:00:00.000Z',
+ '2016-10-01 09:53:04+00:00',
+ '2016-10-01 16:53:04+00:00',
+ null
+ ],
+ [
+ '2016-09-17 00:25:28',
+ 30.0497387,
+ 31.2174421,
+ 'driver_analytics',
+ 1472774400000,
+ null,
+ null,
+ '2016-09-23T07:00:00.000Z',
+ '2016-10-01 09:55:23+00:00',
+ '2016-10-01 16:55:23+00:00',
+ null
+ ],
+ [
+ '2016-09-17 00:26:29',
+ 30.0538936,
+ 31.2165983,
+ 'driver_analytics',
+ 1472774400000,
+ null,
+ 43,
+ '2016-09-23T07:00:00.000Z',
+ '2016-10-01 09:59:53+00:00',
+ '2016-10-01 16:59:53+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:27:31',
+ 30.060911,
+ 31.2148748,
+ 'driver_analytics',
+ 1472774400000,
+ null,
+ 4,
+ '2016-09-23T07:00:00.000Z',
+ '2016-10-01 09:57:11+00:00',
+ '2016-10-01 16:57:11+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:28:35',
+ 30.060334,
+ 31.2212278,
+ 'driver_analytics',
+ 1472774400000,
+ null,
+ 5,
+ '2016-09-23T07:00:00.000Z',
+ '2016-10-01 09:59:27+00:00',
+ '2016-10-01 16:59:27+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:29:40',
+ 30.0554663,
+ 31.2288985,
+ 'driver_analytics',
+ 1472774400000,
+ true,
+ null,
+ '2016-09-23T07:00:00.000Z',
+ '2016-10-01 09:46:36+00:00',
+ '2016-10-01 16:46:36+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:30:03',
+ 30.0614122,
+ 31.2187021,
+ 'driver_gps',
+ 1472774400000,
+ true,
+ 6,
+ '2016-09-23T08:00:00.000Z',
+ '2016-10-01 09:54:31+00:00',
+ '2016-10-01 16:54:31+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:30:03',
+ 30.0612697,
+ 31.2191059,
+ 'driver_gps',
+ 1472774400000,
+ true,
+ 7,
+ '2016-09-23T08:00:00.000Z',
+ '2016-10-01 09:53:35+00:00',
+ '2016-10-01 16:53:35+00:00',
+ '2016-10-10'
+ ],
+ [
+ '2016-09-17 00:30:08',
+ 30.0610977,
+ 31.2194728,
+ 'driver_gps',
+ 1472774400000,
+ true,
+ null,
+ '2016-09-23T08:00:00.000Z',
+ null,
+ null,
+ null
+ ]
+];
export default data;
@@ -617,18 +893,9 @@ export const updatedLayerV2 = {
type: 'Polygon',
coordinates: [
[
- [
- -74.158491,
- 40.835947
- ],
- [
- -74.157914,
- 40.83902
- ],
- [
- -74.148473,
- 40.834522
- ]
+ [-74.158491, 40.835947],
+ [-74.157914, 40.83902],
+ [-74.148473, 40.834522]
]
]
}
@@ -642,18 +909,9 @@ export const updatedLayerV2 = {
type: 'Polygon',
coordinates: [
[
- [
- -74.31687,
- 40.656696
- ],
- [
- -74.319449,
- 40.658154
- ],
- [
- -74.31687,
- 40.656696
- ]
+ [-74.31687, 40.656696],
+ [-74.319449, 40.658154],
+ [-74.31687, 40.656696]
]
]
}
@@ -665,18 +923,7 @@ export const updatedLayerV2 = {
},
geometry: {
type: 'Polygon',
- coordinates: [
- [
- [
- -74.387589,
- 40.632238
- ],
- [
- -74.387589,
- 40.632238
- ]
- ]
- ]
+ coordinates: [[[-74.387589, 40.632238], [-74.387589, 40.632238]]]
}
},
3: {
@@ -688,18 +935,9 @@ export const updatedLayerV2 = {
type: 'Polygon',
coordinates: [
[
- [
- -74.165995,
- 40.747969
- ],
- [
- -74.165987,
- 40.745199
- ],
- [
- -74.165995,
- 40.747969
- ]
+ [-74.165995, 40.747969],
+ [-74.165987, 40.745199],
+ [-74.165995, 40.747969]
]
]
}
@@ -714,48 +952,20 @@ export const updatedLayerV2 = {
coordinates: [
[
[
- [
- -74.566993,
- 41.087294
- ],
- [
- -74.564908,
- 41.089339
- ],
- [
- -74.552353,
- 41.091647
- ],
- [
- -74.566993,
- 41.087294
- ]
+ [-74.566993, 41.087294],
+ [-74.564908, 41.089339],
+ [-74.552353, 41.091647],
+ [-74.566993, 41.087294]
]
],
- [
- [
- [
- -74.593264,
- 41.088526
- ],
- [
- -74.593264,
- 41.088526
- ]
- ]
- ]
+ [[[-74.593264, 41.088526], [-74.593264, 41.088526]]]
]
}
}
},
meta: {
featureTypes: {polygon: true},
- bounds: [
- -74.593264,
- 40.632238,
- -74.148473,
- 41.091647
- ],
+ bounds: [-74.593264, 40.632238, -74.148473, 41.091647],
lightSettings: {
lightsPosition: [
-74.593264,
@@ -768,12 +978,7 @@ export const updatedLayerV2 = {
ambientRatio: 0.4,
diffuseRatio: 0.6,
specularRatio: 0.3,
- lightsStrength: [
- 0.9,
- 0,
- 0.8,
- 0
- ],
+ lightsStrength: [0.9, 0, 0.8, 0],
numberOfLights: 2
},
fixedRadius: false
@@ -789,18 +994,7 @@ export const updatedLayerSimplifiedShape = {
},
geometry: {
type: 'Polygon',
- coordinates: [
- [
- [
- -74.158491,
- 40.835947
- ],
- [
- -74.158491,
- 40.835947
- ]
- ]
- ]
+ coordinates: [[[-74.158491, 40.835947], [-74.158491, 40.835947]]]
}
},
1: {
@@ -812,18 +1006,9 @@ export const updatedLayerSimplifiedShape = {
type: 'Polygon',
coordinates: [
[
- [
- -74.31687,
- 40.656696
- ],
- [
- -74.312298,
- 40.654042
- ],
- [
- -74.31687,
- 40.656696
- ]
+ [-74.31687, 40.656696],
+ [-74.312298, 40.654042],
+ [-74.31687, 40.656696]
]
]
}
@@ -837,22 +1022,10 @@ export const updatedLayerSimplifiedShape = {
type: 'Polygon',
coordinates: [
[
- [
- -74.387589,
- 40.632238
- ],
- [
- -74.382333,
- 40.632417
- ],
- [
- -74.384457,
- 40.630453
- ],
- [
- -74.387589,
- 40.632238
- ]
+ [-74.387589, 40.632238],
+ [-74.382333, 40.632417],
+ [-74.384457, 40.630453],
+ [-74.387589, 40.632238]
]
]
}
@@ -866,22 +1039,10 @@ export const updatedLayerSimplifiedShape = {
type: 'Polygon',
coordinates: [
[
- [
- -74.165995,
- 40.747969
- ],
- [
- -74.163788,
- 40.739201
- ],
- [
- -74.165987,
- 40.745199
- ],
- [
- -74.165995,
- 40.747969
- ]
+ [-74.165995, 40.747969],
+ [-74.163788, 40.739201],
+ [-74.165987, 40.745199],
+ [-74.165995, 40.747969]
]
]
}
@@ -896,30 +1057,12 @@ export const updatedLayerSimplifiedShape = {
coordinates: [
[
[
- [
- -74.566993,
- 41.087294
- ],
- [
- -74.564908,
- 41.089339
- ],
- [
- -74.56559,
- 41.090507
- ],
- [
- -74.557344,
- 41.105958
- ],
- [
- -74.585763,
- 41.083491
- ],
- [
- -74.593264,
- 41.088526
- ]
+ [-74.566993, 41.087294],
+ [-74.564908, 41.089339],
+ [-74.56559, 41.090507],
+ [-74.557344, 41.105958],
+ [-74.585763, 41.083491],
+ [-74.593264, 41.088526]
]
]
]
@@ -928,12 +1071,7 @@ export const updatedLayerSimplifiedShape = {
},
meta: {
featureTypes: {polygon: true},
- bounds: [
- -74.593264,
- 40.630453,
- -74.158491,
- 41.105958
- ],
+ bounds: [-74.593264, 40.630453, -74.158491, 41.105958],
lightSettings: {
lightsPosition: [
-74.593264,
@@ -946,12 +1084,7 @@ export const updatedLayerSimplifiedShape = {
ambientRatio: 0.4,
diffuseRatio: 0.6,
specularRatio: 0.3,
- lightsStrength: [
- 0.9,
- 0,
- 0.8,
- 0
- ],
+ lightsStrength: [0.9, 0, 0.8, 0],
numberOfLights: 2
},
fixedRadius: false
diff --git a/test/fixtures/test-hex-id-data.js b/test/fixtures/test-hex-id-data.js
new file mode 100644
index 000000000..3bce77258
--- /dev/null
+++ b/test/fixtures/test-hex-id-data.js
@@ -0,0 +1,303 @@
+// Copyright (c) 2019 Uber Technologies, Inc.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+
+import {KeplerGlLayers} from 'layers';
+const {H3Layer} = KeplerGlLayers;
+
+export default `hex_id,value
+89283082c2fffff,64
+8928308288fffff,73
+89283082c07ffff,65
+89283082817ffff,74
+89283082c3bffff,66
+89283082883ffff,76
+89283082c03ffff,60
+89283082807ffff,68
+8928308289bffff,49
+89283082c0fffff,41
+89283082c87ffff,50
+89283082d4fffff,45
+89283082c77ffff,41
+89283082c2bffff,53
+89283082803ffff,41
+89283082813ffff,43
+89283082d5bffff,45
+89283082897ffff,40
+89283082c67ffff,42
+89283082d47ffff,51
+89283082dc3ffff,52
+89283082c33ffff,43
+89283082c23ffff,40
+89283082887ffff,36
+89283082d4bffff,36
+892830828bbffff,48
+892830828b7ffff,28
+89283082c17ffff,34
+89283082c6fffff,21
+8928308288bffff,25
+892830828abffff,26
+89283082c27ffff,27
+89283082c8fffff,33
+89283082cafffff,29
+89283082c13ffff,27
+89283082cabffff,22
+89283082c63ffff,26
+89283082d43ffff,30
+89283082d53ffff,19
+892830828a3ffff,28
+89283082d1bffff,20
+89283095367ffff,17
+8928309536bffff,26
+89283082c37ffff,16
+89283082c73ffff,17
+89283082c8bffff,15
+89283082ca7ffff,27
+89283082cb3ffff,32
+89283082c0bffff,26
+89283082ca3ffff,19
+89283082dcfffff,18
+89283082c1bffff,20
+89283082ddbffff,18
+8928309534fffff,16
+89283082d03ffff,15
+89283082cbbffff,21
+89283082cd7ffff,9
+8928309534bffff,9
+892830828c7ffff,13
+89283082cc7ffff,12
+89283082d0bffff,19
+89283082dcbffff,19
+89283082dd3ffff,15
+89283082dd7ffff,15
+892830828d7ffff,13
+89283082d17ffff,5
+8928309536fffff,8
+89283095373ffff,6
+89283082cb7ffff,15
+89283082d83ffff,9
+89283082d07ffff,4
+89283082d0fffff,3
+89283082d13ffff,6
+89283082d9bffff,5
+89283082c83ffff,11
+89283082d8bffff,4
+89283082dc7ffff,5
+89283095377ffff,5
+89283082c97ffff,4
+89283082d7bffff,2
+89283082d8fffff,1
+89283095347ffff,3
+89283095363ffff,2
+8928309537bffff,4
+89283082d93ffff,6
+89283082d73ffff,1
+8928309530bffff,1
+8928309532bffff,1`;
+
+export const dataId = 'h3-hex-id';
+
+export const hexIdDataConfig = {
+ dataId,
+ config: {
+ version: 'v1',
+ config: {
+ visState: {
+ filters: [
+ {
+ dataId,
+ id: 'byjasfp0u',
+ name: 'value',
+ type: 'range',
+ value: [11.2, 18],
+ enlarged: false,
+ plotType: 'histogram',
+ yAxis: null
+ }
+ ],
+ layers: [
+ {
+ id: 'avlgol',
+ type: 'hexagonId',
+ config: {
+ dataId,
+ label: 'H3 Hexagon',
+ color: [241, 92, 23],
+ columns: {
+ hex_id: 'hex_id'
+ },
+ isVisible: true,
+ visConfig: {
+ opacity: 0.8,
+ colorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: [
+ '#5A1846',
+ '#900C3F',
+ '#C70039',
+ '#E3611C',
+ '#F1920E',
+ '#FFC300'
+ ]
+ },
+ coverage: 1,
+ sizeRange: [0, 500],
+ coverageRange: [0, 1],
+ elevationScale: 5
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+ },
+ visualChannels: {
+ colorField: {
+ name: 'value',
+ type: 'integer'
+ },
+ colorScale: 'quantile',
+ sizeField: null,
+ sizeScale: 'linear',
+ coverageField: null,
+ coverageScale: 'linear'
+ }
+ }
+ ],
+ interactionConfig: {
+ tooltip: {
+ fieldsToShow: {
+ [dataId]: ['hex_id', 'value']
+ },
+ enabled: true
+ },
+ brush: {
+ size: 0.5,
+ enabled: false
+ }
+ },
+ layerBlending: 'normal',
+ splitMaps: []
+ },
+ mapStyle: {
+ styleType: 'dark',
+ topLayerGroups: {},
+ visibleLayerGroups: {
+ label: true,
+ road: true,
+ border: false,
+ building: true,
+ water: true,
+ land: true,
+ '3d building': false
+ },
+ mapStyles: {}
+ }
+ }
+ }
+};
+
+export const mergedH3Layer = new H3Layer({
+ id: 'avlgol'
+});
+
+mergedH3Layer.config = {
+ dataId,
+ label: 'H3 Hexagon',
+ color: [241, 92, 23],
+ columns: {
+ hex_id: {
+ value: 'hex_id',
+ fieldIdx: 0
+ }
+ },
+ isVisible: true,
+ highlightColor: [252, 242, 26, 255],
+ isConfigActive: false,
+ colorField: {
+ name: 'value',
+ format: '',
+ tableFieldIndex: 2,
+ type: 'integer',
+ id: 'value'
+ },
+ colorScale: 'quantile',
+ colorDomain: [12, 13, 13, 15, 15, 15, 15, 15, 16, 16, 17, 17, 18, 18],
+ sizeField: null,
+ sizeDomain: [0, 1],
+ sizeScale: 'linear',
+ coverageField: null,
+ coverageScale: 'linear',
+ coverageDomain: [0, 1],
+ visConfig: {
+ opacity: 0.8,
+ colorRange: {
+ name: 'Global Warming',
+ type: 'sequential',
+ category: 'Uber',
+ colors: ['#5A1846', '#900C3F', '#C70039', '#E3611C', '#F1920E', '#FFC300']
+ },
+ coverage: 1,
+ sizeRange: [0, 500],
+ coverageRange: [0, 1],
+ elevationScale: 5
+ },
+ textLabel: [
+ {
+ field: null,
+ color: [255, 255, 255],
+ size: 18,
+ offset: [0, 0],
+ anchor: 'start',
+ alignment: 'center'
+ }
+ ]
+};
+
+export const mergedFilters = [
+ {
+ dataId,
+ id: 'value',
+ name: 'value',
+ type: 'range',
+ value: [11.2, 18],
+ enlarged: false,
+ freeze: true,
+ plotType: 'histogram',
+ yAxis: null,
+ isAnimating: false,
+ fieldIdx: 1,
+ domain: [1, 76],
+ step: 0.1,
+ interval: null,
+ histogram: ['Not tested'],
+ enlargedHistogram: ['Not tested'],
+ speed: 1,
+ fieldType: 'integer',
+ typeOptions: ['range'],
+ fixedDomain: false
+ }
+];
diff --git a/test/helpers/comparison-utils.js b/test/helpers/comparison-utils.js
index 9503615d3..63f9f6dd6 100644
--- a/test/helpers/comparison-utils.js
+++ b/test/helpers/comparison-utils.js
@@ -209,6 +209,9 @@ export function cmpDataset(t, expectedDataset, actualDataset, opt = {}) {
}
export function cmpInteraction(t, expectedInt, actualInt) {
+ t.ok(typeof expectedInt === 'object', 'expected interaction should be an object');
+ t.ok(typeof actualInt === 'object', 'actual interaction should be an object');
+
t.deepEqual(
Object.keys(actualInt).sort(),
Object.keys(expectedInt).sort(),
@@ -222,7 +225,7 @@ export function cmpInteraction(t, expectedInt, actualInt) {
`interaction.${key} should be same type`
);
- if (typeof actualInt[key] === 'object' && !Array.isArray(actualInt[key])) {
+ if (typeof actualInt[key] === 'object' && actualInt[key] !== null && !Array.isArray(actualInt[key])) {
cmpInteraction(t, expectedInt[key], actualInt[key]);
} else {
t.deepEqual(
diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.js
index 8bb47c705..61e7ec0fd 100644
--- a/test/helpers/mock-state.js
+++ b/test/helpers/mock-state.js
@@ -25,6 +25,7 @@ import {getInitialInputStyle} from 'reducers/map-style-updaters';
import keplerGlReducer from 'reducers/core';
import * as VisStateActions from 'actions/vis-state-actions';
import * as MapStyleActions from 'actions/map-style-actions';
+import * as MapStateActions from 'actions/map-state-actions';
import {DEFAULT_TEXT_LABEL} from 'layers/layer-factory';
// fixtures
@@ -268,6 +269,22 @@ function mockStateWithCustomMapStyle() {
return updatedState;
}
+function mockStateWithSplitMaps(state) {
+ const initialState = state || mockStateWithFileUpload();
+
+ const firstLayer = initialState.visState.layers[0];
+
+ const prepareState = applyActions(keplerGlReducer, initialState, [
+ // toggle splitMaps
+ {action: MapStateActions.toggleSplitMap, payload: []},
+
+ // toggleLayerForMap
+ {action: VisStateActions.toggleLayerForMap, payload: [0, firstLayer.id]}
+ ]);
+
+ return prepareState;
+}
+
export const StateWFiles = mockStateWithFileUpload();
export const StateWFilters = mockStateWithFilters();
export const StateWFilesFiltersLayerColor = mockStateWithLayerDimensions(
@@ -275,7 +292,7 @@ export const StateWFilesFiltersLayerColor = mockStateWithLayerDimensions(
);
export const StateWCustomMapStyle = mockStateWithCustomMapStyle();
-
+export const StateWSplitMaps = mockStateWithSplitMaps();
// saved hexagon layer
export const expectedSavedLayer0 = {
id: 'hexagon-2',
diff --git a/test/node/reducers/composer-state-test.js b/test/node/reducers/composer-state-test.js
index 990ad8d95..6be3eb716 100644
--- a/test/node/reducers/composer-state-test.js
+++ b/test/node/reducers/composer-state-test.js
@@ -21,9 +21,12 @@
import test from 'tape';
import keplerGlReducer from 'reducers';
import {addDataToMapUpdater} from 'reducers/combined-updaters';
-import {keplerGlInit} from 'actions/actions';
-import {coreReducerFactory} from 'reducers/core';
import {registerEntry} from 'actions/identity-actions';
+import {processCsvData} from 'processors/data-processor';
+
+import testCsvData, {sampleConfig} from 'test/fixtures/test-csv-data';
+import testHexIdData, {hexIdDataConfig, mergedH3Layer, mergedFilters} from 'test/fixtures/test-hex-id-data';
+import {cmpLayers, cmpFilters, cmpDatasets, cmpInteraction} from 'test/helpers/comparison-utils';
const mockRawData = {
fields: [
@@ -82,7 +85,7 @@ test('#composerStateReducer - addDataToMapUpdater: mapStyle', t => {
t.end();
});
-test('#composerStateReducer - addDataToMapUpdater: mapState should not be centered', t => {
+test('#composerStateReducer - addDataToMapUpdater: mapState should be centered', t => {
// init kepler.gl root and instance
const state = keplerGlReducer({}, registerEntry({id: 'test'})).test;
const mapStateProperties = {
@@ -106,8 +109,129 @@ test('#composerStateReducer - addDataToMapUpdater: mapState should not be center
}
});
- t.equal(newState.mapState.latitude, mapStateProperties.latitude, 'mapstate latitude is set correctly');
- t.equal(newState.mapState.longitude, mapStateProperties.longitude, 'mapstate longitude is set correctly');
+ t.equal(
+ newState.mapState.latitude,
+ 29.23,
+ 'centerMap: true should override mapState config'
+ );
+ t.equal(
+ newState.mapState.longitude,
+ 60.71,
+ 'centerMap: true should override mapState config'
+ );
+
+ t.end();
+});
+
+test('#composerStateReducer - addDataToMapUpdater: keepExistingConfig', t => {
+ const data = processCsvData(testCsvData);
+
+ const state = keplerGlReducer({}, registerEntry({id: 'test'})).test;
+
+ // old state contain splitMaps
+ const oldState = addDataToMapUpdater(state, {
+ payload: {
+ datasets: {
+ data,
+ info: {
+ id: sampleConfig.dataId
+ }
+ },
+ config: sampleConfig.config
+ }
+ });
+
+ const {
+ layers: oldLayers,
+ filters: oldFilters,
+ datasets: oldDatasets,
+ interactionConfig: oldInteractionConfig,
+ splitMaps: oldSplitMaps
+ } = oldState.visState;
+
+ const hexData = processCsvData(testHexIdData);
+ const hexDataId = hexIdDataConfig.dataId;
- t.end()
+ // keepExistingConfig is not defined, default to false
+ const nextState1 = addDataToMapUpdater(oldState, {
+ payload: {
+ datasets: {
+ data: hexData,
+ info: {
+ id: hexDataId
+ }
+ },
+ config: hexIdDataConfig.config
+ }
+ });
+
+ const hexDataset = nextState1.visState.datasets[hexDataId];
+
+ t.equal(hexDataset.allData.length, hexData.rows.length, 'should only have new data');
+ t.equal(hexDataset.fields.length, hexData.fields.length, 'should have same length of fields');
+ t.equal(hexDataset.id, hexDataId, 'should have the id');
+ t.deepEqual(nextState1.visState.splitMaps, [], 'should clear out splitMaps');
+
+ // should only create 1 layer and clear out others
+ cmpLayers(t, [mergedH3Layer], nextState1.visState.layers);
+ cmpFilters(t, mergedFilters, nextState1.visState.filters);
+
+ // add data and config keep existing data and config
+ const nextState2 = addDataToMapUpdater(oldState, {
+ payload: {
+ datasets: {
+ data: hexData,
+ info: {
+ id: hexDataId
+ }
+ },
+ config: hexIdDataConfig.config,
+ options: {
+ keepExistingConfig: true
+ }
+ }
+ });
+
+ const actualVisState = nextState2.visState;
+
+ const expectedVisState = {
+ layers: [...oldLayers, mergedH3Layer],
+ filters: [...oldFilters, ...mergedFilters],
+ datasets: {
+ ...oldDatasets,
+ [hexDataId]: hexDataset
+ },
+ interactionConfig: {
+ ...oldInteractionConfig,
+ tooltip: {
+ ...oldInteractionConfig.tooltip,
+ config: {
+ fieldsToShow: {
+ ...oldInteractionConfig.tooltip.config.fieldsToShow,
+ [hexDataId]: ['hex_id', 'value']
+ }
+ }
+ }
+ },
+ splitMaps: [
+ {layers: {
+ ...oldSplitMaps[0].layers,
+ avlgol: true
+ }},
+ {layers: {
+ ...oldSplitMaps[1].layers,
+ avlgol: true
+ }}
+ ],
+ layerOrder: [2, 0, 1]
+ };
+
+ cmpLayers(t, expectedVisState.layers, actualVisState.layers);
+ cmpFilters(t, expectedVisState.filters, actualVisState.filters);
+ cmpDatasets(t, expectedVisState.datasets, actualVisState.datasets);
+ cmpInteraction(t, expectedVisState.interactionConfig, actualVisState.interactionConfig);
+ t.deepEqual(expectedVisState.layerOrder, actualVisState.layerOrder, 'Should create new layer, move it to the top');
+ t.deepEqual(expectedVisState.splitMaps, actualVisState.splitMaps, 'Should keep existing splitMaps, add new layres to splitMaps');
+
+ t.end();
});
diff --git a/test/node/reducers/vis-state-merger-test.js b/test/node/reducers/vis-state-merger-test.js
index 46d42f1dc..b7e2677d4 100644
--- a/test/node/reducers/vis-state-merger-test.js
+++ b/test/node/reducers/vis-state-merger-test.js
@@ -25,9 +25,9 @@ import {
mergeFilters,
mergeLayers,
mergeInteractions,
- mergeLayerBlending
+ mergeLayerBlending,
+ mergeSplitMaps
} from 'reducers/vis-state-merger';
-import {Messages, Crosshairs} from 'components/common/icons';
import SchemaManager from 'schemas';
import visStateReducer from 'reducers/vis-state';
@@ -83,7 +83,8 @@ import {cmpFilters, cmpLayers} from 'test/helpers/comparison-utils';
import {
InitialState,
StateWFilters,
- StateWFilesFiltersLayerColor
+ StateWFilesFiltersLayerColor,
+ StateWSplitMaps
} from 'test/helpers/mock-state';
test('VisStateMerger.v0 -> mergeFilters -> toEmptyState', t => {
@@ -293,13 +294,12 @@ test('VisStateMerger.current -> mergeLayers -> toEmptyState', t => {
// load data into reducer
const stateWData = visStateReducer(mergedState, updateVisData(parsedData));
- // console.log(stateWData.layers[1].config.textLabel)
// test parsed layers
const genericLayersByOrder = stateToSave.visState.layerOrder.map(
idx => stateToSave.visState.layers[idx]
);
- console.log(genericLayersByOrder[1].config.textLabel)
+
cmpLayers(t, genericLayersByOrder, stateWData.layers, {id: true});
t.end();
});
@@ -403,8 +403,14 @@ test('VisStateMerger.v1.split -> mergeLayers -> toEmptyState', t => {
} else if (key === 'splitMaps') {
t.deepEqual(
mergedState.splitMaps,
+ [],
+ 'Should wait to merge splitMaps'
+ );
+ } else if (key === 'splitMaps') {
+ t.deepEqual(
+ mergedState.splitMapsToBeMerged,
expectedConfig,
- 'Should merge splitMaps'
+ 'Should save to splitMapsToBeMerged'
);
} else if (key === 'interactionToBeMerged') {
t.deepEqual(
@@ -427,11 +433,7 @@ test('VisStateMerger.v1.split -> mergeLayers -> toEmptyState', t => {
const stateWData = visStateReducer(mergedState, updateVisData(parsedData));
// test split Maps
- t.deepEqual(
- stateWData.splitMaps,
- expectedConfig,
- 'should merge splitMaps'
- );
+ t.deepEqual(stateWData.splitMaps, expectedConfig, 'should merge splitMaps');
// test parsed layers
cmpLayers(t, mergedLayersV1Split, stateWData.layers, {id: true});
@@ -440,9 +442,7 @@ test('VisStateMerger.v1.split -> mergeLayers -> toEmptyState', t => {
test('VisStateMerger.v0 -> mergeLayers -> toWorkingState', t => {
const savedConfig = cloneDeep(savedStateV0);
- const parsedConfig = SchemaManager.parseSavedConfig(
- savedConfig.config
- );
+ const parsedConfig = SchemaManager.parseSavedConfig(savedConfig.config);
const oldState = cloneDeep(StateWFilesFiltersLayerColor);
const oldVisState = oldState.visState;
@@ -494,9 +494,7 @@ test('VisStateMerger.v0 -> mergeLayers -> toWorkingState', t => {
test('VisStateMerger.v1 -> mergeLayers -> toWorkingState', t => {
const savedConfig = cloneDeep(savedStateV1);
- const parsedConfig = SchemaManager.parseSavedConfig(
- savedConfig.config
- );
+ const parsedConfig = SchemaManager.parseSavedConfig(savedConfig.config);
const oldState = cloneDeep(StateWFilesFiltersLayerColor);
const oldVisState = oldState.visState;
@@ -927,3 +925,149 @@ test('VisStateMerger - mergeLayerBlending', t => {
t.end();
});
+
+test('VisStateMerger - mergeSplitMaps -> split to split', t => {
+ // state with splitMaps
+ const oldState = cloneDeep(StateWSplitMaps).visState;
+ // saved config with splitMaps
+ const savedConfig = cloneDeep(savedStateV1Split);
+ const parsedConfig = SchemaManager.parseSavedConfig(savedConfig.config);
+
+ // 1. merge State reset current splitMaps
+ const mergedState = visStateReducer(oldState, receiveMapConfig(parsedConfig));
+
+ const expectedToMerge = [
+ {
+ layers: {
+ f24uw1: false,
+ '9x77w7h': true
+ }
+ },
+ {
+ layers: {
+ f24uw1: true,
+ '9x77w7h': false
+ }
+ }
+ ];
+
+ const expectedToMergeAll = [
+ {
+ layers: {
+ f24uw1: false,
+ '9x77w7h': true,
+ 'point-0': false,
+ 'geojson-1': true
+ }
+ },
+ {
+ layers: {
+ f24uw1: true,
+ '9x77w7h': false,
+ 'point-0': true,
+ 'geojson-1': true
+ }
+ }
+ ];
+ t.deepEqual(mergedState.splitMaps, [], 'Should reset splitMaps');
+ t.deepEqual(mergedState.splitMapsToBeMerged, expectedToMerge);
+
+ // 2. merge State keep current splitMaps
+ const mergedState2 = visStateReducer(
+ oldState,
+ receiveMapConfig(parsedConfig, {keepExistingConfig: true})
+ );
+ t.deepEqual(
+ mergedState2.splitMaps,
+ oldState.splitMaps,
+ 'Should keep current splitMaps'
+ );
+ t.deepEqual(
+ mergedState2.splitMapsToBeMerged,
+ expectedToMerge,
+ 'Should save unmerged to splitMapsToBeMerged'
+ );
+
+ const parsedData = SchemaManager.parseSavedData(savedConfig.datasets);
+ // 3. load data into reducer
+ const mergedState3 = visStateReducer(mergedState2, updateVisData(parsedData));
+
+ t.deepEqual(
+ mergedState3.splitMaps,
+ expectedToMergeAll,
+ 'Should merge all splitMaps'
+ );
+ t.deepEqual(
+ mergedState3.splitMapsToBeMerged,
+ [],
+ 'Should empty splitMapsToBeMerged'
+ );
+
+ t.end();
+});
+
+test('VisStateMerger - mergeSplitMaps', t => {
+ const testState1 = {
+ layers: [],
+ splitMaps: [{layers: {a: true}}, {layers: {a: false}}]
+ };
+
+ t.deepEqual(
+ mergeSplitMaps(testState1, []),
+ {...testState1, splitMapsToBeMerged: []},
+ 'should return empty'
+ );
+
+ const testSM = [{layers: {c: true}}, {layers: {c: false}}];
+
+ t.deepEqual(
+ mergeSplitMaps(testState1, testSM),
+ {...testState1, splitMapsToBeMerged: testSM},
+ 'should save non-exist layers to splitMapsToBeMerged'
+ );
+
+ const testState2 = {
+ layers: [{id: 'c', config: {isVisible: true}}],
+ splitMaps: [{layers: {a: true}}, {layers: {a: false}}]
+ };
+
+ t.deepEqual(
+ mergeSplitMaps(testState2, testSM),
+ {
+ ...testState2,
+ splitMaps: [{layers: {a: true, c: true}}, {layers: {a: false, c: false}}],
+ splitMapsToBeMerged: []
+ },
+ 'should merge split maps'
+ );
+
+ const testState3 = {
+ layers: [{id: 'c', config: {isVisible: true}}],
+ splitMaps: []
+ };
+ t.deepEqual(
+ mergeSplitMaps(testState3, testSM),
+ {
+ ...testState3,
+ splitMaps: [{layers: {c: true}}, {layers: {c: false}}],
+ splitMapsToBeMerged: []
+ },
+ 'should create split maps panel and merge split maps'
+ );
+
+ const testState4 = {
+ layers: [{id: 'a', config: {isVisible: true}}, {id: 'b', config: {isVisible: false}}, {id: 'c', config: {isVisible: true}}],
+ splitMaps: []
+ };
+ t.deepEqual(
+ mergeSplitMaps(testState4, testSM),
+ {
+ ...testState4,
+ splitMaps: [{layers: {a: true, c: true}}, {layers: {a: true, c: false}}],
+ splitMapsToBeMerged: []
+ },
+ 'should create split maps panel, add current layer to splitMaps and merge split maps'
+ );
+
+ t.end();
+});