Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
feat(geocoder): make pin color configurable (#3832)
Igor Dykhta6a0fd5fded6c
diff --git a/src/components/src/geocoder-panel.tsx b/src/components/src/geocoder-panel.tsxindex 1e41f27b8..befe7fccd 100644--- a/src/components/src/geocoder-panel.tsx+++ b/src/components/src/geocoder-panel.tsx@@ -19,6 +19,7 @@ import {LayerOrder,MapState,ProtoDataset,+ RGBColor,UiState,Viewport} from '@kepler.gl/types';@@ -37,32 +38,32 @@ type MapViewState = {import {BaseComponentProps} from './types';-const ICON_LAYER = {- id: GEOCODER_LAYER_ID,- type: 'icon',- config: {- label: 'Geocoder Layer',- color: GEOCODER_ICON_COLOR,- dataId: GEOCODER_DATASET_NAME,- columns: {- lat: 'lt',- lng: 'ln',- icon: 'icon',- label: 'text'- },- isVisible: true,- hidden: true,- visConfig: {- radius: GEOCODER_ICON_SIZE+function generateConfig(color: RGBColor) {+ const iconLayer = {+ id: GEOCODER_LAYER_ID,+ type: 'icon',+ config: {+ label: 'Geocoder Layer',+ color,+ dataId: GEOCODER_DATASET_NAME,+ columns: {+ lat: 'lt',+ lng: 'ln',+ icon: 'icon',+ label: 'text'+ },+ isVisible: true,+ hidden: true,+ visConfig: {+ radius: GEOCODER_ICON_SIZE+ }}- }-};+ };-function generateConfig() {return {visState: {- layers: [ICON_LAYER],- layerOrder: [ICON_LAYER.id]+ layers: [iconLayer],+ layerOrder: [iconLayer.id]}};}@@ -146,6 +147,7 @@ interface GeocoderPanelProps {updateMap: ActionHandler<typeof updateMap>;layerOrder: LayerOrder;limitSearch?: boolean;+ color?: RGBColor;transitionDuration?: MapViewState['transitionDuration'];width?: number;@@ -163,6 +165,7 @@ export default function GeocoderPanelFactory(): React.FC<GeocoderPanelProps> {removeDataset,updateMap,limitSearch = false,+ color = GEOCODER_ICON_COLOR,transitionDuration = 3000,width,className,@@ -184,7 +187,7 @@ export default function GeocoderPanelFactory(): React.FC<GeocoderPanelProps> {const updateVisDataPayload = getUpdateVisDataPayload(lat, lon, text);if (updateVisDataPayload) {removeGeocoderDataset();- updateVisData(...updateVisDataPayload, generateConfig());+ updateVisData(...updateVisDataPayload, generateConfig(color));}const bounds = bbox || [@@ -218,7 +221,7 @@ export default function GeocoderPanelFactory(): React.FC<GeocoderPanelProps> {index);},- [index, mapState, removeGeocoderDataset, transitionDuration, updateMap, updateVisData]+ [color, index, mapState, removeGeocoderDataset, transitionDuration, updateMap, updateVisData]);return (diff --git a/src/components/src/kepler-gl.tsx b/src/components/src/kepler-gl.tsxindex 5e7e52ff2..fde112362 100644--- a/src/components/src/kepler-gl.tsx+++ b/src/components/src/kepler-gl.tsx@@ -46,6 +46,7 @@ import {THEME,DEFAULT_MAPBOX_API_URL,GEOCODER_DATASET_NAME,+ GEOCODER_ICON_COLOR,MISSING_MAPBOX_TOKEN} from '@kepler.gl/constants';@@ -321,7 +322,8 @@ export const geoCoderPanelSelector = (removeDataset: props.visStateActions.removeDataset,updateMap: props.mapStateActions.updateMap,appWidth: dimensions.width,- limitSearch: props.visState.interactionConfig.geocoder.config?.limitSearch ?? false+ limitSearch: props.visState.interactionConfig.geocoder.config?.limitSearch ?? false,+ color: props.visState.interactionConfig.geocoder.config?.color ?? GEOCODER_ICON_COLOR});/**diff --git a/src/components/src/side-panel/interaction-panel/geocoder-config.tsx b/src/components/src/side-panel/interaction-panel/geocoder-config.tsxindex d8303b259..960fff063 100644--- a/src/components/src/side-panel/interaction-panel/geocoder-config.tsx+++ b/src/components/src/side-panel/interaction-panel/geocoder-config.tsx@@ -4,8 +4,11 @@import React from 'react';import styled from 'styled-components';import Switch from '../../common/switch';-import {SidePanelSection} from '../../common/styled-components';+import {PanelLabel, SidePanelSection} from '../../common/styled-components';import {FormattedMessage} from '@kepler.gl/localization';+import {GEOCODER_ICON_COLOR} from '@kepler.gl/constants';+import {RGBColor} from '@kepler.gl/types';+import ColorSelectorFactory from '../layer-panel/color-selector';const LimitSwitchWrapper = styled.div`color: ${props => props.theme.labelColor};@@ -19,11 +22,14 @@ const LimitSwitchWrapper = styled.div`type GeocoderConfigProps = {config: {limitSearch: boolean;+ color?: RGBColor;};- onChange: (config: {limitSearch: boolean}) => void;+ onChange: (config: {limitSearch: boolean; color?: RGBColor}) => void;};-function GeocoderConfigFactory() {+GeocoderConfigFactory.deps = [ColorSelectorFactory];++function GeocoderConfigFactory(ColorSelector: ReturnType<typeof ColorSelectorFactory>) {const GeocoderConfig = ({config, onChange}: GeocoderConfigProps) => (<SidePanelSection><LimitSwitchWrapper>@@ -40,6 +46,18 @@ function GeocoderConfigFactory() {secondary/></LimitSwitchWrapper>+ <PanelLabel>+ <FormattedMessage id="geocoder.pinColor" />+ </PanelLabel>+ <ColorSelector+ colorSets={[+ {+ selectedColor: config?.color ?? GEOCODER_ICON_COLOR,+ setColor: color => onChange({...config, color: color as RGBColor})+ }+ ]}+ inputTheme="secondary"+ /></SidePanelSection>);diff --git a/src/layers/src/icon-layer/geocoder-icon.ts b/src/layers/src/icon-layer/geocoder-icon.tsnew file mode 100644index 000000000..c30621365--- /dev/null+++ b/src/layers/src/icon-layer/geocoder-icon.ts@@ -0,0 +1,117 @@+// SPDX-License-Identifier: MIT+// Copyright contributors to the kepler.gl project++import type {SvgIcon} from '@kepler.gl/utils';++/** The geocoder's built-in place icon, bundled to avoid showing fallback geometry while loading. */+const GEOCODER_PLACE_ICON: SvgIcon = {+ id: 'place',+ mesh: {+ positions: [+ [-0.07302158900669638, -0.9963711983816964, 0],+ [-0.21238424246651796, -0.9683471330915179, 0],+ [-0.3993373325892857, -0.8794266183035714, 0],+ [-0.5922809709821429, -0.6874372209821429, 0],+ [-0.6821676548549107, -0.5001143624441965, 0],+ [-0.7105972726004465, -0.3596304757254465, 0],+ [-0.7142857142857143, -0.2857142857142857, 0],+ [-0.7109375000000001, -0.20582393973214297, 0],+ [-0.6841517857142857, -0.05419280133928572, 0],+ [-0.5937500000000001, 0.16631473214285686, 0],+ [-0.5, 0.3191428571428572, 0],+ [-0.029285714285714314, 0.9847142857142859, 0],+ [-0.023263392857142885, 0.9913816964285711, 0],+ [-0.00827232142857134, 0.9990379464285712, 0],+ [0, 1, 0],+ [0.008212053571428546, 0.9990379464285712, 0],+ [0.023243303571428408, 0.9913816964285711, 0],+ [0.029285714285714234, 0.9847142857142859, 0],+ [0.5, 0.3191428571428572, 0],+ [0.5937500000000001, 0.16631473214285686, 0],+ [0.6841517857142857, -0.05419280133928572, 0],+ [0.7109375000000001, -0.20582393973214297, 0],+ [0.7142857142857143, -0.2857142857142857, 0],+ [0.7105972726004464, -0.3596304757254465, 0],+ [0.6821676548549107, -0.5001143624441965, 0],+ [0.5922809709821426, -0.6874372209821429, 0],+ [0.3993373325892859, -0.8794266183035714, 0],+ [0.21238424246651758, -0.9683471330915179, 0],+ [0.07302158900669621, -0.9963711983816964, 0],+ [-0.08815318080357135, 0.1428267299107142, 0],+ [-0.24456445312500005, 0.07700474330357143, 0],+ [-0.36271902901785713, -0.04114983258928562, 0],+ [-0.428541015625, -0.19756110491071432, 0],+ [-0.4374285714285715, -0.2857142857142857, 0],+ [-0.428541015625, -0.37386746651785707, 0],+ [-0.36271902901785713, -0.5302787388392858, 0],+ [-0.24456445312500005, -0.6484333147321428, 0],+ [-0.08815318080357135, -0.7142553013392856, 0],+ [0, -0.7231428571428571, 0],+ [0.08815931919642869, -0.7142553013392856, 0],+ [0.24460965401785725, -0.6484333147321428, 0],+ [0.3628166852678575, -0.5302787388392858, 0],+ [0.42867773437500006, -0.37386746651785707, 0],+ [0.4375714285714286, -0.2857142857142857, 0],+ [0.42867773437500006, -0.19756110491071432, 0],+ [0.3628166852678575, -0.04114983258928562, 0],+ [0.24460965401785725, 0.07700474330357143, 0],+ [0.08815931919642869, 0.1428267299107142, 0],+ [0, 0.1517142857142857, 0],+ [0, -1, 0]+ ],+ cells: [+ [0, 37, 1],+ [0, 38, 37],+ [0, 49, 38],+ [1, 36, 2],+ [1, 37, 36],+ [2, 36, 3],+ [3, 35, 4],+ [3, 36, 35],+ [4, 34, 5],+ [4, 35, 34],+ [5, 33, 6],+ [5, 34, 33],+ [6, 33, 7],+ [7, 32, 8],+ [7, 33, 32],+ [8, 31, 9],+ [8, 32, 31],+ [9, 30, 10],+ [9, 31, 30],+ [10, 29, 11],+ [10, 30, 29],+ [11, 15, 12],+ [11, 16, 15],+ [11, 17, 16],+ [11, 29, 48],+ [11, 48, 17],+ [12, 14, 13],+ [12, 15, 14],+ [17, 47, 18],+ [17, 48, 47],+ [18, 46, 19],+ [18, 47, 46],+ [19, 45, 20],+ [19, 46, 45],+ [20, 44, 21],+ [20, 45, 44],+ [21, 43, 22],+ [21, 44, 43],+ [22, 43, 23],+ [23, 42, 24],+ [23, 43, 42],+ [24, 41, 25],+ [24, 42, 41],+ [25, 40, 26],+ [25, 41, 40],+ [26, 40, 27],+ [27, 39, 28],+ [27, 40, 39],+ [28, 38, 49],+ [28, 39, 38]+ ]+ }+};++export default GEOCODER_PLACE_ICON;diff --git a/src/layers/src/icon-layer/icon-layer.ts b/src/layers/src/icon-layer/icon-layer.tsindex 6b8150d53..ebe7dbc96 100644--- a/src/layers/src/icon-layer/icon-layer.ts+++ b/src/layers/src/icon-layer/icon-layer.ts@@ -15,6 +15,7 @@ import {getTextOffsetByRadius, formatTextLabelData} from '../layer-text-label';import {default as KeplerTable} from '@kepler.gl/table';import {getApplicationConfig, DataContainerInterface} from '@kepler.gl/utils';import type {SvgIcon} from '@kepler.gl/utils';+import GEOCODER_PLACE_ICON from './geocoder-icon';import {ColorRange,VisConfigBoolean,@@ -174,6 +175,16 @@ export default class IconLayer extends Layer {this.iconGeometry = props.iconGeometry || null;this.iconGeometryVersion = 0;+ const fallbackIcons = props.id === GEOCODER_LAYER_ID ? [GEOCODER_PLACE_ICON] : [];+ if (fallbackIcons.length) {+ this.setSvgIcons(+ props.svgIcons ? this.mergeIcons(fallbackIcons, props.svgIcons) : fallbackIcons+ );+ if (props.svgIcons) {+ return;+ }+ }+if (isTest()) {return;}@@ -182,7 +193,7 @@ export default class IconLayer extends Layer {this.setSvgIcons(props.svgIcons);} else {// prepare layer info modal and fetch remote svg icons- this.getSvgIcons();+ this.getSvgIcons(fallbackIcons);}}@@ -242,7 +253,7 @@ export default class IconLayer extends Layer {return Math.pow(2, 14 - zoom + zoomOffset);}- getSvgIcons() {+ getSvgIcons(fallbackIcons: SvgIcon[] = []) {const fetchConfig = {method: 'GET',mode: 'cors',@@ -286,13 +297,14 @@ export default class IconLayer extends Layer {}): Promise.resolve([] as SvgIcon[]);- Promise.all([cdnPromise, customUrlPromise])+ return Promise.all([cdnPromise, customUrlPromise]).then(([cdnIcons, remoteCustomIcons]) => {- const mergedCdnAndRemote = this.mergeIcons(cdnIcons, remoteCustomIcons);+ const iconsWithFallback = this.mergeIcons(fallbackIcons, cdnIcons);+ const mergedCdnAndRemote = this.mergeIcons(iconsWithFallback, remoteCustomIcons);this.setSvgIcons(mergedCdnAndRemote);}).catch(() => {- this.setSvgIcons([]);+ this.setSvgIcons(fallbackIcons);});}diff --git a/src/localization/src/translations/en.ts b/src/localization/src/translations/en.tsindex d8b854997..50313c7cd 100644--- a/src/localization/src/translations/en.ts+++ b/src/localization/src/translations/en.ts@@ -1164,7 +1164,8 @@ ${'```'}},geocoder: {title: 'Enter an address or coordinates, ex 37.79,-122.40',- limitSearch: 'Limit Search to Viewport'+ limitSearch: 'Limit Search to Viewport',+ pinColor: 'Pin Color'},fieldSelector: {clearAll: 'Clear All',diff --git a/src/reducers/src/vis-state-merger.ts b/src/reducers/src/vis-state-merger.tsindex 97c03f6d8..5216da174 100644--- a/src/reducers/src/vis-state-merger.ts+++ b/src/reducers/src/vis-state-merger.ts@@ -637,6 +637,10 @@ function combineInteractionConfigs(configs: SavedInteractionConfig[]): SavedInteif (key === 'geocoder') {combined[key].limitSearch = toBeCombinedProps.some(p => p?.limitSearch);+ const color = toBeCombinedProps.find(p => p?.color)?.color;+ if (color) {+ combined[key].color = color;+ }}if (key === 'legend') {diff --git a/src/reducers/src/vis-state-updaters.ts b/src/reducers/src/vis-state-updaters.tsindex 78b4b93bc..1914221f8 100644--- a/src/reducers/src/vis-state-updaters.ts+++ b/src/reducers/src/vis-state-updaters.ts@@ -135,7 +135,10 @@ import {AnnotationKind,DatasetType,getDatasetRefreshIntervalMs,- getRemoteSourceFormat+ getRemoteSourceFormat,+ GEOCODER_DATASET_NAME,+ GEOCODER_ICON_COLOR,+ GEOCODER_LAYER_ID} from '@kepler.gl/constants';import {AGGREGATION_COUNT_LAYER_TYPES,@@ -337,7 +340,8 @@ export const defaultInteractionConfig: InteractionConfig = {enabled: false,position: null,config: {- limitSearch: false+ limitSearch: false,+ color: GEOCODER_ICON_COLOR}},brush: {@@ -3315,7 +3319,17 @@ export function interactionConfigChangeUpdater(};if (config.id === 'geocoder' && !config.enabled) {- return removeDatasetUpdater(newState, {dataId: 'geocoder_dataset'});+ return removeDatasetUpdater(newState, {dataId: GEOCODER_DATASET_NAME});+ }++ if (config.id === 'geocoder') {+ const geocoderLayer = newState.layers.find(layer => layer.id === GEOCODER_LAYER_ID);+ if (geocoderLayer) {+ return layerConfigChangeUpdater(newState, {+ oldLayer: geocoderLayer,+ newConfig: {color: config.config.color ?? GEOCODER_ICON_COLOR}+ });+ }}return newState;diff --git a/src/types/reducers.d.ts b/src/types/reducers.d.tsindex fc9b8b25d..f79c79e39 100644--- a/src/types/reducers.d.ts+++ b/src/types/reducers.d.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: MIT// Copyright contributors to the kepler.gl project-import {Field, Millisecond} from './types';+import {Field, Millisecond, RGBColor} from './types';import {ColorMap, ColorRange, ColorUI} from './layers';import {MapSplitMode, MapViewMode} from '@kepler.gl/constants';type MapViewState = {@@ -430,6 +430,7 @@ export type Geocoder = BaseInteraction & {position: number[] | null;config: {limitSearch: boolean;+ color: RGBColor;};};export type Brush = BaseInteraction & {diff --git a/src/types/schemas.d.ts b/src/types/schemas.d.tsindex 38548cc63..c51b9cb2a 100644--- a/src/types/schemas.d.ts+++ b/src/types/schemas.d.ts@@ -40,6 +40,7 @@ export type SavedInteractionConfig = {geocoder: {enabled: boolean;limitSearch?: boolean;+ color?: RGBColor;};brush: InteractionConfig['brush']['config'] & {enabled: boolean;diff --git a/test/browser/components/geocoder-panel-test.js b/test/browser/components/geocoder-panel-test.jsindex b99a556f6..1f72bdf46 100644--- a/test/browser/components/geocoder-panel-test.js+++ b/test/browser/components/geocoder-panel-test.js@@ -6,12 +6,20 @@ import React from 'react';import sinon from 'sinon';import test from 'tape';import {IntlWrapper, mountWithTheme} from 'test/helpers/component-utils';-import {GeocoderPanelFactory, appInjector, testForCoordinates} from '@kepler.gl/components';+import {+ ColorSelectorFactory,+ GeocoderConfigFactory,+ GeocoderPanelFactory,+ appInjector,+ testForCoordinates+} from '@kepler.gl/components';import {cmpDatasetData, cmpObjectKeys} from '../../helpers/comparison-utils';import {InitialState} from 'test/helpers/mock-state';const GeocoderPanel = appInjector.get(GeocoderPanelFactory);+const GeocoderConfig = appInjector.get(GeocoderConfigFactory);+const ColorSelector = appInjector.get(ColorSelectorFactory);const MAPBOX_TOKEN = 'pk.eyJ1Ijoi.d9YD6z';test('GeocoderPanel - render', t => {@@ -27,6 +35,7 @@ test('GeocoderPanel - render', t => {height: 800};const layerOrder = ['layer_1', 'layer_2'];+ const pinColor = [0, 128, 255];const mockUiState = InitialState.uiState;const mockGeoItem = {@@ -106,7 +115,7 @@ test('GeocoderPanel - render', t => {type: 'icon',config: {label: 'Geocoder Layer',- color: [255, 0, 0],+ color: pinColor,dataId: 'geocoder_dataset',columns: {lat: 'lt',@@ -141,6 +150,7 @@ test('GeocoderPanel - render', t => {removeDataset={removeDataset}updateMap={updateMap}layerOrder={layerOrder}+ color={pinColor}/></IntlWrapper>);@@ -215,6 +225,33 @@ test('GeocoderPanel - render', t => {t.end();});+test('GeocoderConfig - change pin color', t => {+ const onChange = sinon.spy();+ const color = [255, 0, 0];+ const nextColor = [0, 128, 255];+ const wrapper = mountWithTheme(+ <IntlWrapper>+ <GeocoderConfig config={{limitSearch: false, color}} onChange={onChange} />+ </IntlWrapper>+ );++ const colorSelector = wrapper.find(ColorSelector);+ t.equal(colorSelector.length, 1, 'Should render a pin color selector');+ t.deepEqual(+ colorSelector.props().colorSets[0].selectedColor,+ color,+ 'Should display the configured pin color'+ );++ colorSelector.props().colorSets[0].setColor(nextColor);+ t.ok(+ onChange.calledOnce && onChange.calledWith({limitSearch: false, color: nextColor}),+ 'Should update the geocoder pin color'+ );++ t.end();+});+test('Geocoder -> testForCoordinates', t => {t.deepEqual(testForCoordinates('21.22,-138.0'),diff --git a/test/browser/layer-tests/icon-layer-specs.js b/test/browser/layer-tests/icon-layer-specs.jsindex 20f5df37b..b2f8a77c3 100644--- a/test/browser/layer-tests/icon-layer-specs.js+++ b/test/browser/layer-tests/icon-layer-specs.js@@ -4,12 +4,18 @@import test from 'tape';import React from 'react';import {mount} from 'enzyme';+import Window from 'global/window';import sinon from 'sinon';import sinonStubPromise from 'sinon-stub-promise';import {getDistanceScales, zoomToScale} from '@math.gl/web-mercator';import {copyTableAndUpdate} from '@kepler.gl/table';import {KeplerGlLayers} from '@kepler.gl/layers';-import {DEFAULT_TEXT_LABEL, PROJECTED_PIXEL_SIZE_MULTIPLIER} from '@kepler.gl/constants';+import {getApplicationConfig, initApplicationConfig} from '@kepler.gl/utils';+import {+ DEFAULT_TEXT_LABEL,+ GEOCODER_LAYER_ID,+ PROJECTED_PIXEL_SIZE_MULTIPLIER+} from '@kepler.gl/constants';sinonStubPromise(sinon);@@ -51,6 +57,33 @@ const mockSvgIcons = [}];+const fallbackPlaceIcon = {+ id: 'place',+ mesh: {+ positions: [+ [1, 1, 0],+ [2, 1, 0],+ [1, 2, 0]+ ],+ cells: [[0, 1, 2]]+ }+};++const customPlaceIcon = {+ id: 'place',+ mesh: {+ positions: [+ [10, 10, 0],+ [20, 10, 0],+ [10, 20, 0]+ ],+ cells: [[0, 1, 2]]+ }+};++const fallbackPlaceGeometry = [1, -1, 0, 2, -1, 0, 1, -2, 0];+const customPlaceGeometry = [10, -10, 0, 20, -10, 0, 10, -20, 0];+test('#IconLayer -> constructor', t => {const TEST_CASES = {CREATE: [@@ -77,6 +110,105 @@ test('#IconLayer -> constructor', t => {t.end();});+test('#IconLayer -> geocoder uses bundled place icon', t => {+ const layer = new IconLayer({id: GEOCODER_LAYER_ID, dataId: ''});++ t.ok(layer.iconGeometry.place?.length, 'should initialize place geometry synchronously');+ t.equal(layer.iconGeometryVersion, 1, 'should render the bundled geometry immediately');++ t.end();+});++test('#IconLayer -> geocoder constructor icons override bundled place icon', t => {+ const layer = new IconLayer({+ id: GEOCODER_LAYER_ID,+ dataId: '',+ svgIcons: [customPlaceIcon]+ });++ t.deepEqual(+ layer.iconGeometry.place,+ customPlaceGeometry,+ 'should use constructor geometry for the place icon'+ );++ t.end();+});++test('#IconLayer -> geocoder remote icons override fallback', async t => {+ const previousConfig = getApplicationConfig();+ const previousCustomIconUrl = previousConfig.customIconUrl;+ const previousCustomIcons = previousConfig.customIcons;+ const customIconUrl = 'https://example.com/custom-icons.json';+ const fetchStub = sinon.stub(Window, 'fetch').callsFake(url =>+ Promise.resolve({+ ok: true,+ json: () => Promise.resolve({svgIcons: url === customIconUrl ? [customPlaceIcon] : []})+ })+ );++ try {+ initApplicationConfig({customIconUrl, customIcons: []});+ const layer = new IconLayer({id: GEOCODER_LAYER_ID, dataId: ''});++ await layer.getSvgIcons([fallbackPlaceIcon]);++ t.deepEqual(+ layer.iconGeometry.place,+ customPlaceGeometry,+ 'should replace fallback geometry with the remote place icon'+ );+ t.ok(fetchStub.calledWith(customIconUrl), 'should load the configured remote icons');+ } finally {+ fetchStub.restore();+ initApplicationConfig({+ customIconUrl: previousCustomIconUrl,+ customIcons: previousCustomIcons+ });+ }++ t.end();+});++test('#IconLayer -> geocoder keeps fallback when remote icons fail', async t => {+ const previousConfig = getApplicationConfig();+ const previousCustomIconUrl = previousConfig.customIconUrl;+ const previousCustomIcons = previousConfig.customIcons;+ const customIconUrl = 'https://example.com/unavailable-icons.json';+ const fetchStub = sinon+ .stub(Window, 'fetch')+ .callsFake(url =>+ Promise.resolve(+ url === customIconUrl+ ? {ok: false, status: 500}+ : {ok: true, json: () => Promise.resolve({svgIcons: []})}+ )+ );+ const consoleErrorStub = sinon.stub(console, 'error');++ try {+ initApplicationConfig({customIconUrl, customIcons: []});+ const layer = new IconLayer({id: GEOCODER_LAYER_ID, dataId: ''});++ await layer.getSvgIcons([fallbackPlaceIcon]);++ t.deepEqual(+ layer.iconGeometry.place,+ fallbackPlaceGeometry,+ 'should preserve fallback geometry after a remote load failure'+ );+ } finally {+ consoleErrorStub.restore();+ fetchStub.restore();+ initApplicationConfig({+ customIconUrl: previousCustomIconUrl,+ customIcons: previousCustomIcons+ });+ }++ t.end();+});+test('#IconLayer -> formatLayerData', t => {const filteredIndex = [0, 2, 4];diff --git a/test/node/reducers/vis-state-merger-combine-configs-test.spec.js b/test/node/reducers/vis-state-merger-combine-configs-test.spec.jsindex 822776350..c11cd0584 100644--- a/test/node/reducers/vis-state-merger-combine-configs-test.spec.js+++ b/test/node/reducers/vis-state-merger-combine-configs-test.spec.js@@ -24,7 +24,7 @@ const TEST_CASES = [compareMode: true,compareType: 'absolute'},- geocoder: {enabled: true},+ geocoder: {enabled: true, color: [255, 0, 0]},brush: {enabled: true, size: 0.5},coordinate: {enabled: false}},@@ -38,7 +38,7 @@ const TEST_CASES = [compareMode: true,compareType: 'relative'},- geocoder: {enabled: true},+ geocoder: {enabled: true, color: [0, 128, 255]},brush: {enabled: true, size: 2},coordinate: {enabled: false}},@@ -85,7 +85,7 @@ const TEST_CASES = [compareMode: true,compareType: 'relative'},- geocoder: {enabled: true, limitSearch: false},+ geocoder: {enabled: true, limitSearch: false, color: [255, 0, 0]},brush: {enabled: true, size: 3},coordinate: {enabled: false}}diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex 0d6feed09..8b14e576d 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -59,11 +59,14 @@ import {INTERVAL,LAYER_TYPES,SYNC_TIMELINE_MODES,+ GEOCODER_DATASET_NAME,+ GEOCODER_ICON_COLOR,+ GEOCODER_LAYER_ID,KEPLER_COLOR_PALETTES,colorPaletteToColorRange} from '@kepler.gl/constants';-const {ArcLayer, PointLayer, GeojsonLayer, LineLayer, TripLayer} = KeplerGlLayers;+const {ArcLayer, PointLayer, GeojsonLayer, IconLayer, LineLayer, TripLayer} = KeplerGlLayers;// fixturesimport testData, {@@ -4686,6 +4689,34 @@ test('#visStateReducer -> INTERACTION_CONFIG_CHANGE', t => {t.end();});+test('#visStateReducer -> INTERACTION_CONFIG_CHANGE updates geocoder pin color', t => {+ const geocoderLayer = new IconLayer({+ id: GEOCODER_LAYER_ID,+ dataId: GEOCODER_DATASET_NAME,+ color: GEOCODER_ICON_COLOR+ });+ const initialState = {+ ...INITIAL_VIS_STATE,+ layers: [geocoderLayer],+ layerData: [{}]+ };+ const color = [0, 128, 255];+ const geocoderConfig = {+ ...defaultInteractionConfig.geocoder,+ enabled: true,+ config: {+ ...defaultInteractionConfig.geocoder.config,+ color+ }+ };++ const nextState = reducer(initialState, VisStateActions.interactionConfigChange(geocoderConfig));++ t.deepEqual(nextState.interactionConfig.geocoder.config.color, color, 'should store pin color');+ t.deepEqual(nextState.layers[0].config.color, color, 'should update an existing geocoder pin');+ t.end();+});+test('#visStateReducer -> SHOW_DATASET_TABLE', t => {const initialState = StateWFiles.visState;const nextState = reducer(initialState, VisStateActions.showDatasetTable('abc'));diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.jsindex 478853c5d..74eb9518d 100644--- a/test/node/schemas/vis-state-schema-test.js+++ b/test/node/schemas/vis-state-schema-test.js@@ -225,7 +225,8 @@ test('#visStateSchema -> v1 -> save load interaction', t => {},geocoder: {enabled: false,- limitSearch: false+ limitSearch: false,+ color: [255, 0, 0]},legend: {enabled: false,@@ -312,7 +313,8 @@ test('#visStateSchema -> v1 -> save load interaction -> tooltip format', t => {},geocoder: {enabled: false,- limitSearch: false+ limitSearch: false,+ color: [255, 0, 0]},legend: {enabled: false,