UNPKG

kepler.gl

Version:

kepler.gl is a webgl based application to visualize large scale location data in the browser

656 lines (626 loc) 91.9 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.editCustomMapStyleUpdater = exports.addCustomMapStyleUpdater = exports.INITIAL_MAP_STYLE = void 0; exports.getInitialInputStyle = getInitialInputStyle; exports.getMapStyles = getMapStyles; exports.setBackgroundColorUpdater = exports.set3dBuildingColorUpdater = exports.resetMapConfigMapStyleUpdater = exports.requestMapStylesUpdater = exports.removeCustomMapStyleUpdater = exports.receiveMapConfigUpdater = exports.mapStyleChangeUpdater = exports.mapConfigChangeUpdater = exports.loadMapStylesUpdater = exports.loadMapStyleErrUpdater = exports.loadCustomMapStyleUpdater = exports.inputMapStyleUpdater = exports.initMapStyleUpdater = void 0; var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); var _tasks = _interopRequireWildcard(require("react-palm/tasks")); var _lodash = _interopRequireDefault(require("lodash.clonedeep")); var _console = _interopRequireDefault(require("global/console")); var _utils = require("@kepler.gl/utils"); var _commonUtils = require("@kepler.gl/common-utils"); var _constants = require("@kepler.gl/constants"); var _tasks2 = require("@kepler.gl/tasks"); var _d3Color = require("d3-color"); var _actions = require("@kepler.gl/actions"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // SPDX-License-Identifier: MIT // Copyright contributors to the kepler.gl project // Utils var getDefaultState = function getDefaultState() { var visibleLayerGroups = {}; var topLayerGroups = {}; return { styleType: _constants.DEFAULT_BASE_MAP_STYLE, visibleLayerGroups: visibleLayerGroups, topLayerGroups: topLayerGroups, mapStyles: _constants.DEFAULT_MAP_STYLES.reduce(function (accu, curr) { return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, curr.id, curr)); }, {}), // save mapbox access token mapboxApiAccessToken: null, mapboxApiUrl: _constants.DEFAULT_MAPBOX_API_URL, mapStylesReplaceDefault: false, inputStyle: getInitialInputStyle(), threeDBuildingColor: (0, _utils.hexToRgb)(_constants.DEFAULT_BLDG_COLOR), custom3DBuildingColor: false, backgroundColor: (0, _utils.hexToRgb)(_constants.DEFAULT_BACKGROUND_COLOR), isLoading: {}, bottomMapStyle: undefined, topMapStyle: undefined }; }; /** * Updaters for `mapStyle`. Can be used in your root reducer to directly modify kepler.gl's state. * Read more about [Using updaters](../advanced-usage/using-updaters.md) * @public * @example * * 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; */ /* eslint-disable @typescript-eslint/no-unused-vars */ // @ts-ignore var mapStyleUpdaters = null; /* eslint-enable @typescript-eslint/no-unused-vars */ /** * Default initial `mapStyle` * @memberof mapStyleUpdaters * @constant * @property styleType - Default: `'dark'` * @property visibleLayerGroups - Default: `{}` * @property topLayerGroups - Default: `{}` * @property mapStyles - mapping from style key to style object * @property mapboxApiAccessToken - Default: `null` * @Property mapboxApiUrl - Default null * @Property mapStylesReplaceDefault - Default: `false` * @property inputStyle - Default: `{}` * @property threeDBuildingColor - Default: `[r, g, b]` * @property backgroundColor - Default: `[r, g, b]` * @public */ var INITIAL_MAP_STYLE = exports.INITIAL_MAP_STYLE = getDefaultState(); /** * Create two map styles from preset map style, one for top map one for bottom * * @param {string} styleType - current map style * @param {Object} visibleLayerGroups - visible layers of bottom map * @param {Object} topLayerGroups - visible layers of top map * @param {Object} mapStyles - a dictionary of all map styles * @returns {Object} bottomMapStyle | topMapStyle | isRaster */ function getMapStyles(_ref) { var styleType = _ref.styleType, visibleLayerGroups = _ref.visibleLayerGroups, topLayerGroups = _ref.topLayerGroups, mapStyles = _ref.mapStyles; var mapStyle = mapStyles[styleType]; // style might not be loaded yet if (!mapStyle || !mapStyle.style) { return {}; } var editable = Object.keys(visibleLayerGroups).length; var bottomMapStyle = !editable ? mapStyle.style : (0, _utils.editBottomMapStyle)({ id: styleType, mapStyle: mapStyle, visibleLayerGroups: visibleLayerGroups }); var hasTopLayer = editable > 0 && Object.values(topLayerGroups).some(function (v) { return v; }); // mute top layer if not visible in bottom layer var topLayers = hasTopLayer && Object.keys(topLayerGroups).reduce(function (accu, key) { return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, key, topLayerGroups[key] && visibleLayerGroups[key])); }, {}); var topMapStyle = hasTopLayer ? (0, _utils.editTopMapStyle)({ id: styleType, mapStyle: mapStyle, visibleLayerGroups: topLayers }) : null; return { bottomMapStyle: bottomMapStyle, topMapStyle: topMapStyle, editable: editable }; } function findLayerFillColor(layer) { return layer && layer.paint && layer.paint['background-color']; } // need to be careful because some basemap layer.paint['background-color'] values may be an interpolate array expression instead of a color string // https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#paint-background-background-color // https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/#interpolate function getPaintColor(color) { if (Array.isArray(color) && color[0] === 'interpolate') { // get color of first zoom break // ["interpolate", ["linear"], ["zoom"], 11, "hsl(35, 32%, 91%)", 13, "hsl(35, 12%, 89%)"] return color[4]; } return color; } function get3DBuildingColor(style) { // set building color to be the same as the background color. if (!style.style) { return (0, _utils.hexToRgb)(_constants.DEFAULT_BLDG_COLOR); } var backgroundLayer = (style.style.layers || []).find(function (_ref2) { var id = _ref2.id; return id === 'background'; }); var buildingLayer = (style.style.layers || []).find(function (_ref3) { var id = _ref3.id; return id.match(/building/); }); var buildingColor = findLayerFillColor(buildingLayer) || findLayerFillColor(backgroundLayer) || _constants.DEFAULT_BLDG_COLOR; // brighten or darken building based on style var operation = style.id.match(/(?=(dark|night))/) ? 'brighter' : 'darker'; var alpha = 0.2; var rgbObj = (0, _d3Color.rgb)(buildingColor)[operation]([alpha]); return [rgbObj.r, rgbObj.g, rgbObj.b]; } function getBackgroundColorFromStyleBaseLayer(style, backupBackgroundColor) { var _colorMaybeToRGB; if (!style.style) { return (0, _utils.colorMaybeToRGB)(backupBackgroundColor) || backupBackgroundColor; } // @ts-expect-error style.style not typed var baseLayer = (style.style.layers || []).find(function (_ref4) { var id = _ref4.id; return _constants.BASE_MAP_BACKGROUND_LAYER_IDS.includes(id); }); var backgroundColorOfBaseLayer = getPaintColor(findLayerFillColor(baseLayer)); var newBackgroundColor = typeof backgroundColorOfBaseLayer === 'string' ? backgroundColorOfBaseLayer : backupBackgroundColor; var newBackgroundColorAsRGBArray = (_colorMaybeToRGB = (0, _utils.colorMaybeToRGB)(newBackgroundColor) // if newBackgroundColor was in string HSL format it can introduce RGB numbers with decimals, // which may render the background-color CSS of the <StyledMap> container incorrectly when using our own color utils `rgbToHex()` // so we attempt to round to nearest integer here ) === null || _colorMaybeToRGB === void 0 ? void 0 : _colorMaybeToRGB.map(function (channelNumber) { return Math.round(channelNumber); }); return newBackgroundColorAsRGBArray || backupBackgroundColor; } // determine new backgroundColor from either previous state basemap style, previous state backgroundColor, or the DEFAULT_BACKGROUND_COLOR function getBackgroundColor(previousState, styleType) { var previousStateMapStyle = previousState.mapStyles[previousState.styleType]; var backupBackgroundColor = previousState.backgroundColor || _constants.DEFAULT_BACKGROUND_COLOR; var backgroundColor = styleType === _constants.NO_MAP_ID ? // if the style has switched to the "no basemap" style, // attempt to detect backgroundColor of the previous basemap if it was a mapbox basemap // and set it as the "no basemap" backgroundColor getBackgroundColorFromStyleBaseLayer(previousStateMapStyle, backupBackgroundColor) : // otherwise leave it alone and rely on the previous state's preexisting backgroundColor // or DEFAULT_BACKGROUND_COLOR as a last resort backupBackgroundColor; return backgroundColor; } function getLayerGroupsFromStyle(style) { return Array.isArray(style === null || style === void 0 ? void 0 : style.layers) ? _constants.DEFAULT_LAYER_GROUPS.filter(function (lg) { return style.layers.filter(lg.filter).length; }) : []; } // Updaters /** * @memberof mapStyleUpdaters * @public */ var requestMapStylesUpdater = exports.requestMapStylesUpdater = function requestMapStylesUpdater(state, _ref5) { var _ref5$payload = _ref5.payload, mapStyles = _ref5$payload.mapStyles, onSuccess = _ref5$payload.onSuccess; var toLoad = Object.keys(mapStyles).reduce(function (accu, id) { return _objectSpread(_objectSpread({}, accu), !state.isLoading[id] ? (0, _defineProperty2["default"])({}, id, mapStyles[id]) : {}); }, {}); var loadMapStyleTasks = getLoadMapStyleTasks(toLoad, state.mapboxApiAccessToken, state.mapboxApiUrl, onSuccess); var isLoading = Object.keys(toLoad).reduce(function (accu, key) { return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, key, true)); }, {}); var nextState = _objectSpread(_objectSpread({}, state), {}, { isLoading: isLoading }); return (0, _tasks.withTask)(nextState, loadMapStyleTasks); }; /** * Propagate `mapStyle` reducer with `mapboxApiAccessToken` and `mapStylesReplaceDefault`. * if mapStylesReplaceDefault is true mapStyles is emptied; loadMapStylesUpdater() will * populate mapStyles. * * @memberof mapStyleUpdaters * @public */ var initMapStyleUpdater = exports.initMapStyleUpdater = function initMapStyleUpdater(state, _ref7) { var _ref7$payload = _ref7.payload, payload = _ref7$payload === void 0 ? {} : _ref7$payload; return _objectSpread(_objectSpread({}, state), {}, { // save mapbox access token to map style state mapboxApiAccessToken: payload.mapboxApiAccessToken || state.mapboxApiAccessToken, mapboxApiUrl: payload.mapboxApiUrl || state.mapboxApiUrl, mapStyles: !payload.mapStylesReplaceDefault ? state.mapStyles : {}, mapStylesReplaceDefault: payload.mapStylesReplaceDefault || false }); }; // }); /** * Update `visibleLayerGroups`to change layer group visibility * @memberof mapStyleUpdaters * @public */ var mapConfigChangeUpdater = exports.mapConfigChangeUpdater = function mapConfigChangeUpdater(state, action) { return _objectSpread(_objectSpread(_objectSpread({}, state), action.payload), getMapStyles(_objectSpread(_objectSpread({}, state), action.payload))); }; var hasStyleObject = function hasStyleObject(style) { return (0, _utils.isPlainObject)(style === null || style === void 0 ? void 0 : style.style); }; /** * Change to another map style. The selected style should already been loaded into `mapStyle.mapStyles` * @memberof mapStyleUpdaters * @public */ var mapStyleChangeUpdater = exports.mapStyleChangeUpdater = function mapStyleChangeUpdater(state, _ref8) { var _state$mapStyles$styl, _state$mapStyles$styl2; var _ref8$payload = _ref8.payload, styleType = _ref8$payload.styleType, onSuccess = _ref8$payload.onSuccess; if ( // we might not have received the style yet !state.mapStyles[styleType] || // or if it is a managed custom style asset // and if it has not been hydrated with URL info yet (during app first initialization) // and it does not have a style object (during adding a custom style) ((_state$mapStyles$styl = state.mapStyles[styleType]) === null || _state$mapStyles$styl === void 0 ? void 0 : _state$mapStyles$styl.custom) === 'MANAGED' && !((_state$mapStyles$styl2 = state.mapStyles[styleType]) !== null && _state$mapStyles$styl2 !== void 0 && _state$mapStyles$styl2.url) && !hasStyleObject(state.mapStyles[styleType])) { return state; } if (!hasStyleObject(state.mapStyles[styleType])) { // style hasn't loaded yet return requestMapStylesUpdater(_objectSpread(_objectSpread({}, state), {}, { styleType: styleType }), { payload: { mapStyles: (0, _defineProperty2["default"])({}, styleType, state.mapStyles[styleType]), onSuccess: onSuccess } }); } var defaultLGVisibility = (0, _utils.getDefaultLayerGroupVisibility)(state.mapStyles[styleType]); var visibleLayerGroups = (0, _utils.mergeLayerGroupVisibility)(defaultLGVisibility, state.visibleLayerGroups); var threeDBuildingColor = state.custom3DBuildingColor ? state.threeDBuildingColor : get3DBuildingColor(state.mapStyles[styleType]); // determine new backgroundColor from either previous state basemap style, previous state backgroundColor, or the DEFAULT_BACKGROUND_COLOR var backgroundColor = getBackgroundColor(state, styleType); return _objectSpread(_objectSpread({}, state), {}, { styleType: styleType, visibleLayerGroups: visibleLayerGroups, threeDBuildingColor: threeDBuildingColor, backgroundColor: backgroundColor }, getMapStyles(_objectSpread(_objectSpread({}, state), {}, { visibleLayerGroups: visibleLayerGroups, styleType: styleType }))); }; /** * Callback when load map style success * @memberof mapStyleUpdaters * @public */ var loadMapStylesUpdater = exports.loadMapStylesUpdater = function loadMapStylesUpdater(state, action) { var _ref9 = action.payload || {}, newStyles = _ref9.newStyles, onSuccess = _ref9.onSuccess; var addLayerGroups = Object.keys(newStyles).reduce(function (accu, id) { return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, id, _objectSpread(_objectSpread({}, newStyles[id]), {}, { layerGroups: newStyles[id].layerGroups || getLayerGroupsFromStyle(newStyles[id].style) }))); }, {}); // reset isLoading var isLoading = Object.keys(state.isLoading).reduce(function (accu, key) { return _objectSpread(_objectSpread({}, accu), state.isLoading[key] && hasStyleObject(newStyles[key]) ? (0, _defineProperty2["default"])({}, key, false) : (0, _defineProperty2["default"])({}, key, state.isLoading[key])); }, {}); // add new styles to state var newState = _objectSpread(_objectSpread({}, state), {}, { isLoading: isLoading, mapStyles: _objectSpread(_objectSpread({}, state.mapStyles), addLayerGroups) }); var tasks = createActionTask(onSuccess, { styleType: state.styleType }); var nextState = newStyles[state.styleType] ? mapStyleChangeUpdater(newState, { payload: { styleType: state.styleType } }) : newState; return tasks ? (0, _tasks.withTask)(nextState, tasks) : nextState; }; function createActionTask(action, payload) { if (typeof action === 'function') { return (0, _tasks2.ACTION_TASK)().map(function () { return action(payload); }); } return null; } /** * Callback when load map style error * @memberof mapStyleUpdaters * @public */ // do nothing for now, if didn't load, skip it var loadMapStyleErrUpdater = exports.loadMapStyleErrUpdater = function loadMapStyleErrUpdater(state, _ref12) { var _ref12$payload = _ref12.payload, ids = _ref12$payload.ids, error = _ref12$payload.error; _console["default"].error(error); // reset isLoading var isLoading = Object.keys(state.isLoading).reduce(function (accu, key) { return _objectSpread(_objectSpread({}, accu), state.isLoading[key] && (ids || []).includes(key) ? (0, _defineProperty2["default"])({}, key, false) : (0, _defineProperty2["default"])({}, key, state.isLoading[key])); }, {}); return _objectSpread(_objectSpread({}, state), {}, { isLoading: isLoading }); }; /** * Load map style object when pass in saved map config * @memberof mapStyleUpdaters * @param state `mapStyle` * @param action * @param action.payload saved map config `{mapStyle, visState, mapState}` * @returns nextState or `react-pam` tasks to load map style object */ var receiveMapConfigUpdater = exports.receiveMapConfigUpdater = function receiveMapConfigUpdater(state, _ref15) { var config = _ref15.payload.config; var _ref16 = config || {}, mapStyle = _ref16.mapStyle; if (!mapStyle) { return state; } // merge default mapStyles var merged = mapStyle.mapStyles ? _objectSpread(_objectSpread({}, mapStyle), {}, { mapStyles: _objectSpread(_objectSpread({}, mapStyle.mapStyles), state.mapStyles) }) : mapStyle; // set custom3DBuildingColor: true if mapStyle contains threeDBuildingColor // @ts-expect-error merged.custom3DBuildingColor = // @ts-expect-error Boolean(mapStyle.threeDBuildingColor) || merged.custom3DBuildingColor; var newState = mapConfigChangeUpdater(state, { payload: merged }); return mapStyleChangeUpdater(newState, { payload: { styleType: newState.styleType } }); }; function getLoadMapStyleTasks(mapStyles, mapboxApiAccessToken, mapboxApiUrl, onSuccess) { return [_tasks["default"].all(Object.values(mapStyles) // @ts-expect-error .map(function (_ref17) { var id = _ref17.id, url = _ref17.url, accessToken = _ref17.accessToken; return { id: id, url: (0, _utils.getStyleDownloadUrl)(url, accessToken || mapboxApiAccessToken, mapboxApiUrl) }; }).map(_tasks2.LOAD_MAP_STYLE_TASK)).bimap( // success function (results) { return (0, _actions.loadMapStyles)(results.reduce(function (accu, _ref18) { var id = _ref18.id, style = _ref18.style; return _objectSpread(_objectSpread({}, accu), {}, (0, _defineProperty2["default"])({}, id, _objectSpread(_objectSpread({}, mapStyles[id]), {}, { style: style }))); }, {}), onSuccess); }, // error function (err) { return (0, _actions.loadMapStyleErr)(Object.keys(mapStyles), err); })]; } /** * Reset map style config to initial state * @memberof mapStyleUpdaters * @param state `mapStyle` * @returns nextState * @public */ var resetMapConfigMapStyleUpdater = exports.resetMapConfigMapStyleUpdater = function resetMapConfigMapStyleUpdater(state) { var emptyConfig = _objectSpread(_objectSpread(_objectSpread({}, INITIAL_MAP_STYLE), {}, { mapboxApiAccessToken: state.mapboxApiAccessToken, mapboxApiUrl: state.mapboxApiUrl, mapStylesReplaceDefault: state.mapStylesReplaceDefault }, state.initialState), {}, { mapStyles: state.mapStyles, initialState: state.initialState }); return mapStyleChangeUpdater(emptyConfig, { payload: { styleType: emptyConfig.styleType } }); }; /** * Callback when a custom map style object is received * @memberof mapStyleUpdaters * @public */ var loadCustomMapStyleUpdater = exports.loadCustomMapStyleUpdater = function loadCustomMapStyleUpdater(state, _ref19) { var _ref19$payload = _ref19.payload, icon = _ref19$payload.icon, style = _ref19$payload.style, error = _ref19$payload.error; return _objectSpread(_objectSpread({}, state), {}, { // @ts-expect-error inputStyle: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, state.inputStyle), style ? { id: state.inputStyle.custom === 'MANAGED' ? state.inputStyle.id // custom MANAGED type : // @ts-expect-error style.id || (0, _commonUtils.generateHashId)(), // custom LOCAL type // make a copy of the style object style: (0, _lodash["default"])(style), // @ts-expect-error label: state.inputStyle.label || style.name, // gathering layer group info from style json layerGroups: getLayerGroupsFromStyle(style) } : {}), icon ? { icon: icon } : {}), error !== undefined ? { error: error } : {}) }); }; /** * Input a custom map style object * @memberof mapStyleUpdaters * @public */ var inputMapStyleUpdater = exports.inputMapStyleUpdater = function inputMapStyleUpdater(state, _ref20) { var _updated$icon, _updated$url, _updated$url2; var _ref20$payload = _ref20.payload, inputStyle = _ref20$payload.inputStyle, mapState = _ref20$payload.mapState; var updated = _objectSpread(_objectSpread({}, state.inputStyle), inputStyle); // differentiate between either a url to hosted style json that needs an icon url, // or an icon already available client-side as a data uri var isUpdatedIconDataUri = (_updated$icon = updated.icon) === null || _updated$icon === void 0 ? void 0 : _updated$icon.startsWith('data:image'); var isMapboxStyleUrl = ((_updated$url = updated.url) === null || _updated$url === void 0 ? void 0 : _updated$url.startsWith('mapbox://')) || ((_updated$url2 = updated.url) === null || _updated$url2 === void 0 ? void 0 : _updated$url2.includes('mapbox.com')); var icon = !isUpdatedIconDataUri && isMapboxStyleUrl ? // Get image icon urls only for mapbox map lib. (0, _utils.getStyleImageIcon)({ mapState: mapState, styleUrl: updated.url || '', mapboxApiAccessToken: updated.accessToken || state.mapboxApiAccessToken || '', mapboxApiUrl: state.mapboxApiUrl || _constants.DEFAULT_MAPBOX_API_URL }) : updated.icon; return _objectSpread(_objectSpread({}, state), {}, { inputStyle: _objectSpread(_objectSpread({}, updated), {}, { isValid: true, icon: icon }) }); }; /** * Add map style from user input to reducer and set it to current style * This action is called when user click confirm after putting in a valid style url in the custom map style dialog. * It should not be called from outside kepler.gl without a valid `inputStyle` in the `mapStyle` reducer. * @memberof mapStyleUpdaters */ var addCustomMapStyleUpdater = exports.addCustomMapStyleUpdater = function addCustomMapStyleUpdater(state) { var styleId = state.inputStyle.id; if (!styleId) return state; var newState = getNewStateWithCustomMapStyle(state); // set new style return mapStyleChangeUpdater(newState, { payload: { styleType: styleId } }); }; /** * Edit map style from user input to reducer. * This action is called when user clicks confirm after editing an existing custom style in the custom map style dialog. * It should not be called from outside kepler.gl without a valid `inputStyle` in the `mapStyle` reducer. * @memberof mapStyleUpdaters */ var editCustomMapStyleUpdater = exports.editCustomMapStyleUpdater = function editCustomMapStyleUpdater(state) { return getNewStateWithCustomMapStyle(state); }; function getNewStateWithCustomMapStyle(state) { var styleId = state.inputStyle.id; if (!styleId) return state; return _objectSpread(_objectSpread({}, state), {}, { // @ts-expect-error Property 'layerGroups' is missing in type 'InputStyle' but required in type 'BaseMapStyle'. Legacy case? mapStyles: _objectSpread(_objectSpread({}, state.mapStyles), {}, (0, _defineProperty2["default"])({}, styleId, _objectSpread(_objectSpread({}, state.mapStyles[styleId]), state.inputStyle))), // set to default inputStyle: getInitialInputStyle() }); } /** * Remove a custom map style from `state.mapStyle.mapStyles`. * @memberof mapStyleUpdaters */ var removeCustomMapStyleUpdater = exports.removeCustomMapStyleUpdater = function removeCustomMapStyleUpdater(state, action) { var id = action.payload.id; // eslint-disable-next-line @typescript-eslint/no-unused-vars var _state$mapStyles = state.mapStyles, _ = _state$mapStyles[id], restOfMapStyles = (0, _objectWithoutProperties2["default"])(_state$mapStyles, [id].map(_toPropertyKey)); var newState = _objectSpread(_objectSpread({}, state), {}, { mapStyles: restOfMapStyles }); if (state.styleType === id) { // if removing a custom style that is also the current active base map, // then reset to the default active base map (`mapStyle.styleType`) return mapStyleChangeUpdater(newState, { payload: { styleType: getDefaultState().styleType } }); } return newState; }; /** * Updates 3d building color * @memberof mapStyleUpdaters */ var set3dBuildingColorUpdater = exports.set3dBuildingColorUpdater = function set3dBuildingColorUpdater(state, _ref21) { var color = _ref21.payload; return _objectSpread(_objectSpread({}, state), {}, { threeDBuildingColor: color, custom3DBuildingColor: true }); }; /** * Updates background color * @memberof mapStyleUpdaters */ var setBackgroundColorUpdater = exports.setBackgroundColorUpdater = function setBackgroundColorUpdater(state, _ref22) { var color = _ref22.payload; return _objectSpread(_objectSpread({}, state), {}, { backgroundColor: color }); }; /** * Return the initial input style * @return Object */ function getInitialInputStyle() { return { id: null, accessToken: null, error: false, isValid: false, label: null, style: null, url: null, icon: null, custom: 'LOCAL', uploadedFile: null }; } //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJfdGFza3MiLCJfaW50ZXJvcFJlcXVpcmVXaWxkY2FyZCIsInJlcXVpcmUiLCJfbG9kYXNoIiwiX2ludGVyb3BSZXF1aXJlRGVmYXVsdCIsIl9jb25zb2xlIiwiX3V0aWxzIiwiX2NvbW1vblV0aWxzIiwiX2NvbnN0YW50cyIsIl90YXNrczIiLCJfZDNDb2xvciIsIl9hY3Rpb25zIiwiX2dldFJlcXVpcmVXaWxkY2FyZENhY2hlIiwiZSIsIldlYWtNYXAiLCJyIiwidCIsIl9fZXNNb2R1bGUiLCJfdHlwZW9mIiwiaGFzIiwiZ2V0IiwibiIsIl9fcHJvdG9fXyIsImEiLCJPYmplY3QiLCJkZWZpbmVQcm9wZXJ0eSIsImdldE93blByb3BlcnR5RGVzY3JpcHRvciIsInUiLCJoYXNPd25Qcm9wZXJ0eS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