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
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;INITIAL_MAP_STYLE
Default initial mapStyle
Properties
styleTypestring Default:'dark'visibleLayerGroupsObject Default:{}topLayerGroupsObject Default:{}mapStylesObject mapping from style key to style objectmapboxApiAccessTokenstring Default:nullinputStyleObject Default:{}threeDBuildingColorArray Default:[r, g, b]
initMapStyleUpdater
Propagate mapStyle reducer with mapboxApiAccessToken and mapStylesReplaceDefault. if mapStylesReplaceDefault is true mapStyles is emptied; loadMapStylesUpdater() will populate mapStyles.
Action:
keplerGlInit
Parameters
stateObject
Returns Object nextState
inputMapStyleUpdater
Input a custom map style object
Action:
inputMapStyle
Parameters
stateObjectmapStyleactionObject action objectaction.payloadObject inputStyleaction.payload.urlstring style url e.g.'mapbox://styles/heshan/xxxxxyyyyzzz'action.payload.idstring style url e.g.'custom_style_1'action.payload.styleObject actual mapbox style jsonaction.payload.namestring style nameaction.payload.layerGroupsObject layer groups that can be used to set map layer visibilityaction.payload.iconObject icon image data url
action.payload.inputStyleaction.payload.mapState
Returns Object nextState
loadCustomMapStyleUpdater
Callback when a custom map style object is received
Action:
loadCustomMapStyle
Parameters
stateObjectmapStyle
Returns Object nextState
loadMapStyleErrUpdater
Callback when load map style error
Action:
loadMapStyleErr
Parameters
Returns Object nextState
loadMapStylesUpdater
Callback when load map style success
Action:
loadMapStyles
Parameters
stateObjectmapStyle
Returns Object nextState
mapConfigChangeUpdater
Update visibleLayerGroupsto change layer group visibility
Action:
mapConfigChange
Parameters
stateObjectmapStyle
Returns Object nextState
mapStyleChangeUpdater
Change to another map style. The selected style should already been loaded into mapStyle.mapStyles
Action:
mapStyleChange
Parameters
stateObjectmapStyle
Returns Object nextState
resetMapConfigMapStyleUpdater
Reset map style config to initial state
Action:
resetMapConfig
Parameters
stateObjectmapStyle
Returns Object nextState
Last updated
Was this helpful?