Search…
map-style

Table of Contents

mapStyleUpdaters

Updaters for mapStyle. Can be used in your root reducer to directly modify kepler.gl's state. Read more about Using updaters
Examples
1
import keplerGlReducer, {mapStyleUpdaters} from 'kepler.gl/reducers';
2
// Root Reducer
3
const reducers = combineReducers({
4
keplerGl: keplerGlReducer,
5
app: appReducer
6
});
7
8
const composedReducer = (state, action) => {
9
switch (action.type) {
10
// click button to hide label from background map
11
case 'CLICK_BUTTON':
12
return {
13
...state,
14
keplerGl: {
15
...state.keplerGl,
16
foo: {
17
...state.keplerGl.foo,
18
mapStyle: mapStyleUpdaters.mapConfigChangeUpdater(
19
mapStyle,
20
{payload: {visibleLayerGroups: {label: false, road: true, background: true}}}
21
)
22
}
23
}
24
};
25
}
26
return reducers(state, action);
27
};
28
29
export default composedReducer;
Copied!

INITIAL_MAP_STYLE

Default initial mapStyle

Properties

    styleType string Default: 'dark'
    visibleLayerGroups Object Default: {}
    topLayerGroups Object Default: {}
    mapStyles Object mapping from style key to style object
    mapboxApiAccessToken string Default: null
    inputStyle Object Default: {}
    threeDBuildingColor Array Default: [r, g, b]

initMapStyleUpdater

Propagate mapStyle reducer with mapboxApiAccessToken and mapStylesReplaceDefault. if mapStylesReplaceDefault is true mapStyles is emptied; loadMapStylesUpdater() will populate mapStyles.
Parameters
Returns Object nextState

inputMapStyleUpdater

Input a custom map style object
Parameters
    state Object mapStyle
    action Object action object
      action.payload Object inputStyle
        action.payload.url string style url e.g. 'mapbox://styles/heshan/xxxxxyyyyzzz'
        action.payload.id string style url e.g. 'custom_style_1'
        action.payload.style Object actual mapbox style json
        action.payload.name string style name
        action.payload.layerGroups Object layer groups that can be used to set map layer visibility
        action.payload.icon Object icon image data url
      action.payload.inputStyle
      action.payload.mapState
Returns Object nextState

loadCustomMapStyleUpdater

Callback when a custom map style object is received
Parameters
    state Object mapStyle
    action Object
      action.payload Object
        action.payload.icon string
        action.payload.style Object
        action.payload.error any
      action.payload.icon
      action.payload.style
      action.payload.error
Returns Object nextState

loadMapStyleErrUpdater

Callback when load map style error
Parameters
Returns Object nextState

loadMapStylesUpdater

Callback when load map style success
Parameters
Returns Object nextState

mapConfigChangeUpdater

Update visibleLayerGroupsto change layer group visibility
Parameters
    state Object mapStyle
    action Object
      action.payload Object new config {visibleLayerGroups: {label: false, road: true, background: true}}
Returns Object nextState

mapStyleChangeUpdater

Change to another map style. The selected style should already been loaded into mapStyle.mapStyles
Parameters
Returns Object nextState

resetMapConfigMapStyleUpdater

Reset map style config to initial state
Parameters
Returns Object nextState
Last modified 1yr ago