Updaters for mapStyle
. Can be used in your root reducer to directly modify kepler.gl's state.
Read more about Using updaters
Examples
import keplerGlReducer, {mapStyleUpdaters} from 'kepler.gl/reducers';
// Root Reducer
const reducers = combineReducers({
keplerGl: keplerGlReducer,
app: appReducer
});
const composedReducer = (state, action) => {
switch (action.type) {
// click button to hide label from background map
case 'CLICK_BUTTON':
return {
...state,
keplerGl: {
...state.keplerGl,
foo: {
...state.keplerGl.foo,
mapStyle: mapStyleUpdaters.mapConfigChangeUpdater(
mapStyle,
{payload: {visibleLayerGroups: {label: false, road: true, background: true}}}
)
}
}
};
}
return reducers(state, action);
};
export default composedReducer;
Default initial mapStyle
styleType
string Default:'dark'
visibleLayerGroups
Object Default:{}
topLayerGroups
Object Default:{}
mapStyles
Object mapping from style key to style objectmapboxApiAccessToken
string Default:null
inputStyle
Object Default:{}
threeDBuildingColor
Array Default:[r, g, b]
Propagate mapStyle
reducer with mapboxApiAccessToken
and mapStylesReplaceDefault
.
if mapStylesReplaceDefault is true mapStyles is emptied; loadMapStylesUpdater() will
populate mapStyles.
- Action:
keplerGlInit
Parameters
Returns Object nextState
Input a custom map style object
- Action:
inputMapStyle
Parameters
state
ObjectmapStyle
action
Object action objectaction.payload
Object inputStyleaction.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 jsonaction.payload.name
string style nameaction.payload.layerGroups
Object layer groups that can be used to set map layer visibilityaction.payload.icon
Object icon image data url
action.payload.inputStyle
action.payload.mapState
Returns Object nextState
Callback when a custom map style object is received
- Action:
loadCustomMapStyle
Parameters
Returns Object nextState
Callback when load map style error
- Action:
loadMapStyleErr
Parameters
Returns Object nextState
Callback when load map style success
- Action:
loadMapStyles
Parameters
Returns Object nextState
Update visibleLayerGroups
to change layer group visibility
- Action:
mapConfigChange
Parameters
state
ObjectmapStyle
action
Objectaction.payload
Object new config{visibleLayerGroups: {label: false, road: true, background: true}}
Returns Object nextState
Change to another map style. The selected style should already been loaded into mapStyle.mapStyles
- Action:
mapStyleChange
Parameters
Returns Object nextState
Reset map style config to initial state
- Action:
resetMapConfig
Parameters
state
ObjectmapStyle
Returns Object nextState