Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[Feat] Geocoder Search (#1068)
Valentine Panchinb39b8f27db98
diff --git a/examples/custom-reducer/src/configurations/config.js b/examples/custom-reducer/src/configurations/config.jsindex aec5c7177..8ac94e215 100644--- a/examples/custom-reducer/src/configurations/config.js+++ b/examples/custom-reducer/src/configurations/config.js@@ -119,6 +119,9 @@ export default {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',diff --git a/examples/demo-app/src/data/sample-geojson-config.js b/examples/demo-app/src/data/sample-geojson-config.jsindex e44ba0330..8db3c51a1 100644--- a/examples/demo-app/src/data/sample-geojson-config.js+++ b/examples/demo-app/src/data/sample-geojson-config.js@@ -171,6 +171,9 @@ const config = {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal'diff --git a/examples/demo-app/src/data/sample-hex-id-csv.js b/examples/demo-app/src/data/sample-hex-id-csv.jsindex 30ca48814..81702d1b2 100644--- a/examples/demo-app/src/data/sample-hex-id-csv.js+++ b/examples/demo-app/src/data/sample-hex-id-csv.js@@ -172,6 +172,9 @@ export const config = {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',diff --git a/examples/demo-app/src/data/sample-icon-csv.js b/examples/demo-app/src/data/sample-icon-csv.jsindex df6f74f92..c2f376ab5 100644--- a/examples/demo-app/src/data/sample-icon-csv.js+++ b/examples/demo-app/src/data/sample-icon-csv.js@@ -243,6 +243,9 @@ export const config = {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',diff --git a/examples/open-modal/src/configurations/config.js b/examples/open-modal/src/configurations/config.jsindex aec5c7177..8ac94e215 100644--- a/examples/open-modal/src/configurations/config.js+++ b/examples/open-modal/src/configurations/config.js@@ -119,6 +119,9 @@ export default {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',diff --git a/package.json b/package.jsonindex c2aa4a174..39ad934c7 100644--- a/package.json+++ b/package.json@@ -130,6 +130,7 @@"react-lifecycles-compat": "^3.0.4","react-map-gl": "^5.0.3","react-map-gl-draw": "0.14.8",+ "react-mapbox-gl-geocoder": "^1.1.0","react-markdown": "^4.0.6","react-modal": "^3.8.1","react-onclickoutside": "^6.7.1",diff --git a/src/components/geocoder-panel.js b/src/components/geocoder-panel.jsnew file mode 100644index 000000000..c9e5a4634--- /dev/null+++ b/src/components/geocoder-panel.js@@ -0,0 +1,229 @@+// Copyright (c) 2020 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React, {Component} from 'react';+import PropTypes from 'prop-types';+import styled from 'styled-components';+import {SidePanelSection, PanelLabel} from './common/styled-components';+import {FormattedMessage} from 'react-intl';+import Geocoder from 'react-mapbox-gl-geocoder';+import Processors from 'processors';+import {fitBounds, addDataToMap, removeDataset} from 'actions';++const GEOCODER_DATASET_NAME = 'geocoder_dataset';+const QUERY_PARAMS = {};+const GEO_OFFSET = 0.1;+const ICON_LAYER = {+ id: 'geocoder_layer',+ type: 'icon',+ config: {+ label: 'Geocoder Layer',+ color: [255, 0, 0],+ dataId: GEOCODER_DATASET_NAME,+ columns: {+ lat: 'lt',+ lng: 'ln',+ icon: 'icon',+ label: 'text'+ },+ isVisible: true,+ hidden: true,+ visConfig: {+ radius: 80+ }+ }+};++const GeocoderPanelContent = styled.div`+ background-color: ${props => props.theme.panelBackground};+ padding: 0.5em 1em;+ position: absolute;+ top: 20px;+ left: 50%;+ margin-left: -20em;+ width: 40em;+ box-sizing: border-box;+`;++const GeocoderWrapper = styled.div`+ color: ${props => props.theme.textColor};+ font-size: ${props => props.theme.fontSize};++ .react-geocoder {+ position: relative;+ }++ .react-geocoder input {+ ${props => props.theme.secondaryInput};+ }++ .react-geocoder-results {+ background-color: ${props => props.theme.panelBackground};+ position: absolute;+ width: 43.5em;+ }++ .react-geocoder-item {+ ${props => props.theme.dropdownListItem};+ ${props => props.theme.textTruncate};+ }++ .remove-layer {+ background: transparent;+ border: none;+ bottom: 28px;+ color: ${props => props.theme.textColor};+ cursor: pointer;+ display: inline;+ font-size: 16px;+ padding: 2px 8px;+ position: absolute;+ right: 16px;++ :hover,+ :focus,+ :active {+ background: transparent !important;+ border: none;+ box-shadow: 0;+ color: ${props => props.theme.textColor};+ opacity: 0.6;+ outline: none;+ }+ }+`;++function generateGeocoderDataset(lat, lon, text) {+ return {+ data: Processors.processRowObject([+ {+ lt: lat,+ ln: lon,+ icon: 'place',+ text+ }+ ]),+ id: GEOCODER_DATASET_NAME,+ info: {+ hidden: true,+ id: GEOCODER_DATASET_NAME,+ label: GEOCODER_DATASET_NAME+ }+ };+}++function isValid(key) {+ return /pk\..*\..*/.test(key);+}++export class GeocoderPanel extends Component {+ static propTypes = {+ isGeocoderEnabled: PropTypes.bool.isRequired,+ mapboxApiAccessToken: PropTypes.string.isRequired+ };++ state = {+ selectedGeoItem: null+ };++ removeGeocoderDataset() {+ this.props.dispatch(removeDataset(GEOCODER_DATASET_NAME));+ }++ onSelected = (viewport = null, geoItem) => {+ const {+ center: [lon, lat],+ text,+ bbox+ } = geoItem;+ this.removeGeocoderDataset();+ this.props.dispatch(+ addDataToMap({+ datasets: [generateGeocoderDataset(lat, lon, text)],+ options: {+ keepExistingConfig: true+ },+ config: {+ version: 'v1',+ config: {+ visState: {+ layers: [ICON_LAYER]+ }+ }+ }+ })+ );+ this.props.dispatch(+ fitBounds(bbox || [lon - GEO_OFFSET, lat - GEO_OFFSET, lon + GEO_OFFSET, lat + GEO_OFFSET])+ );+ this.setState({+ selectedGeoItem: geoItem+ });+ };++ removeMarker = () => {+ this.setState({+ selectedGeoItem: null+ });+ this.removeGeocoderDataset();+ };++ render() {+ const {isGeocoderEnabled, mapboxApiAccessToken} = this.props;+ return (+ <GeocoderPanelContent+ className="geocoder-panel"+ style={{display: isGeocoderEnabled ? 'block' : 'none'}}+ >+ <SidePanelSection>+ <PanelLabel>+ <FormattedMessage id={'geocoder.title'} />+ </PanelLabel>+ <GeocoderWrapper>+ {isValid(mapboxApiAccessToken) && (+ <Geocoder+ mapboxApiAccessToken={mapboxApiAccessToken}+ onSelected={this.onSelected}+ hideOnSelect+ pointZoom={15}+ viewport={{}}+ queryParams={QUERY_PARAMS}+ />+ )}+ {this.state.selectedGeoItem && (+ <button+ type="button"+ className="btn btn-primary remove-layer"+ onClick={this.removeMarker}+ title="Remove marker"+ >+ ×+ </button>+ )}+ </GeocoderWrapper>+ </SidePanelSection>+ </GeocoderPanelContent>+ );+ }+}++export default function GeocoderPanelFactory() {+ return GeocoderPanel;+}diff --git a/src/components/index.js b/src/components/index.jsindex 97dfafe9f..0bc0702d3 100644--- a/src/components/index.js+++ b/src/components/index.js@@ -30,6 +30,7 @@ export {default as MapContainerFactory} from './map-container';export {default as BottomWidgetFactory} from './bottom-widget';export {default as ModalContainerFactory} from './modal-container';export {default as PlotContainerFactory} from './plot-container';+export {default as GeocoderPanelFactory} from './geocoder-panel';// // side panel factoriesexport {diff --git a/src/components/kepler-gl.js b/src/components/kepler-gl.jsindex 4fe20c4f7..20cb54183 100644--- a/src/components/kepler-gl.js+++ b/src/components/kepler-gl.js@@ -53,6 +53,7 @@ import BottomWidgetFactory from './bottom-widget';import ModalContainerFactory from './modal-container';import PlotContainerFactory from './plot-container';import NotificationPanelFactory from './notification-panel';+import GeoCoderPanelFactory from './geocoder-panel';import {generateHashId} from 'utils/utils';import {validateToken} from 'utils/mapbox-utils';@@ -92,6 +93,7 @@ const GlobalStyle = styled.div`KeplerGlFactory.deps = [BottomWidgetFactory,+ GeoCoderPanelFactory,MapContainerFactory,ModalContainerFactory,SidePanelFactory,@@ -101,6 +103,7 @@ KeplerGlFactory.deps = [function KeplerGlFactory(BottomWidget,+ GeoCoderPanel,MapContainer,ModalContainer,SidePanel,@@ -237,7 +240,8 @@ function KeplerGlFactory(mapStateActions,mapStyleActions,uiStateActions,- providerActions+ providerActions,+ dispatch} = this.props;const availableProviders = this.availableProviders(this.props);@@ -364,6 +368,13 @@ function KeplerGlFactory(setExportImageError={uiStateActions.setExportImageError}/>)}+ {!uiState.readOnly && interactionConfig.geocoder.enabled && (+ <GeoCoderPanel+ isGeocoderEnabled={interactionConfig.geocoder.enabled}+ mapboxApiAccessToken={mapboxApiAccessToken}+ dispatch={dispatch}+ />+ )}<BottomWidgetfilters={filters}datasets={datasets}diff --git a/src/components/side-panel/layer-manager.js b/src/components/side-panel/layer-manager.jsindex 117c43c3d..826989c3b 100644--- a/src/components/side-panel/layer-manager.js+++ b/src/components/side-panel/layer-manager.js@@ -231,22 +231,25 @@ function LayerManagerFactory(AddDataButton, LayerPanel, SourceDataCatalog) {helperClass="sorting-layers"useDragHandle>- {layerOrder.map((layerIdx, index) => (- <SortableItem- key={`layer-${layerIdx}`}- index={index}- isSorting={this.state.isSorting}- >- <LayerPanel- {...panelProps}- {...layerActions}- sortData={layerIdx}- key={layers[layerIdx].id}- idx={layerIdx}- layer={layers[layerIdx]}- />- </SortableItem>- ))}+ {layerOrder.map(+ (layerIdx, index) =>+ !layers[layerIdx].config.hidden && (+ <SortableItem+ key={`layer-${layerIdx}`}+ index={index}+ isSorting={this.state.isSorting}+ >+ <LayerPanel+ {...panelProps}+ {...layerActions}+ sortData={layerIdx}+ key={layers[layerIdx].id}+ idx={layerIdx}+ layer={layers[layerIdx]}+ />+ </SortableItem>+ )+ )}</SortableContainer></SidePanelSection><SidePanelSection>diff --git a/src/layers/base-layer.js b/src/layers/base-layer.jsindex 233e25c0c..f88c7c545 100644--- a/src/layers/base-layer.js+++ b/src/layers/base-layer.js@@ -131,7 +131,7 @@ export default class Layer {}get noneLayerDataAffectingProps() {- return ['label', 'opacity', 'thickness', 'isVisible'];+ return ['label', 'opacity', 'thickness', 'isVisible', 'hidden'];}get visualChannels() {@@ -295,6 +295,7 @@ export default class Layer {isVisible: props.isVisible || false,isConfigActive: props.isConfigActive || false,highlightColor: props.highlightColor || [252, 242, 26, 255],+ hidden: props.hidden || false,// TODO: refactor this into separate visual Channel config// color by field, domain is set by filters, field, scale type@@ -998,6 +999,7 @@ export default class Layer {pickable: true,wrapLongitude: true,parameters: {depthTest: Boolean(mapState.dragRotate || this.config.visConfig.enable3d)},+ hidden: this.config.hidden,// visconfigopacity: this.config.visConfig.opacity,highlightColor: this.config.highlightColor,diff --git a/src/layers/mapbox-utils.js b/src/layers/mapbox-utils.jsindex 11aad3d28..a3208c4cb 100644--- a/src/layers/mapbox-utils.js+++ b/src/layers/mapbox-utils.js@@ -50,6 +50,7 @@ export function generateMapboxLayers(data: layerData[index].data,isVisible: layer.config.isVisible,config: layerData[index].config,+ hidden: layer.config.hidden,sourceId: layerData[index].config.source}};diff --git a/src/localization/en.js b/src/localization/en.jsindex d443b8b13..e0944bbd9 100644--- a/src/localization/en.js+++ b/src/localization/en.js@@ -375,7 +375,8 @@ export default {interactions: {tooltip: 'Tooltip',brush: 'Brush',- coordinate: 'Coordinates'+ coordinate: 'Coordinates',+ geocoder: 'Geocoder'},layerBlending: {title: 'Layer Blending',@@ -429,6 +430,9 @@ export default {fileNotSupported: 'File {errorFiles} is not supported.',or: 'or'},+ geocoder: {+ title: 'Geocoder'+ },density: 'density','Bug Report': 'Bug Report','User Guide': 'User Guide',diff --git a/src/reducers/vis-state-merger.js b/src/reducers/vis-state-merger.jsindex 828b597dd..b765322ef 100644--- a/src/reducers/vis-state-merger.js+++ b/src/reducers/vis-state-merger.js@@ -468,7 +468,8 @@ export function validateLayerWithData({fields, id: dataId}, savedLayer, layerCladataId,label: savedLayer.config.label,color: savedLayer.config.color,- isVisible: savedLayer.config.isVisible+ isVisible: savedLayer.config.isVisible,+ hidden: savedLayer.config.hidden});// find column fieldIdxdiff --git a/src/reducers/vis-state-updaters.js b/src/reducers/vis-state-updaters.jsindex c87ae3e7d..6ab32feef 100644--- a/src/reducers/vis-state-updaters.js+++ b/src/reducers/vis-state-updaters.js@@ -453,48 +453,6 @@ export function layerVisConfigChangeUpdater(state, action) {return updateStateWithLayerAndData(state, {layer: newLayer, idx});}-/* eslint-enable max-statements */--/**- * Update `interactionConfig`- * @memberof visStateUpdaters- * @param {Object} state `visState`- * @param {Object} action action- * @param {Object} action.config new config as key value map: `{tooltip: {enabled: true}}`- * @returns {Object} nextState- * @public- */-export function interactionConfigChangeUpdater(state, action) {- const {config} = action;-- const interactionConfig = {- ...state.interactionConfig,- ...{[config.id]: config}- };-- // Don't enable tooltip and brush at the same time- // but coordinates can be shown at all time- const contradict = ['brush', 'tooltip'];-- if (- contradict.includes(config.id) &&- config.enabled &&- !state.interactionConfig[config.id].enabled- ) {- // only enable one interaction at a time- contradict.forEach(k => {- if (k !== config.id) {- interactionConfig[k] = {...interactionConfig[k], enabled: false};- }- });- }-- return {- ...state,- interactionConfig- };-}-/*** Update filter property* @memberof visStateUpdaters@@ -1069,6 +1027,54 @@ export const layerHoverUpdater = (state, action) => ({hoverInfo: action.info});+/* eslint-enable max-statements */++/**+ * Update `interactionConfig`+ * @memberof visStateUpdaters+ * @param {Object} state `visState`+ * @param {Object} action action+ * @param {Object} action.config new config as key value map: `{tooltip: {enabled: true}}`+ * @returns {Object} nextState+ * @public+ */+export function interactionConfigChangeUpdater(state, action) {+ const {config} = action;++ const interactionConfig = {+ ...state.interactionConfig,+ ...{[config.id]: config}+ };++ // Don't enable tooltip and brush at the same time+ // but coordinates can be shown at all time+ const contradict = ['brush', 'tooltip'];++ if (+ contradict.includes(config.id) &&+ config.enabled &&+ !state.interactionConfig[config.id].enabled+ ) {+ // only enable one interaction at a time+ contradict.forEach(k => {+ if (k !== config.id) {+ interactionConfig[k] = {...interactionConfig[k], enabled: false};+ }+ });+ }++ const newState = {+ ...state,+ interactionConfig+ };++ if (config.id === 'geocoder' && !config.enabled) {+ return removeDatasetUpdater(newState, {key: 'geocoder_dataset'});+ }++ return newState;+}+/*** Trigger layer click event with clicked object* @memberof visStateUpdatersdiff --git a/src/schemas/vis-state-schema.js b/src/schemas/vis-state-schema.jsindex edda37a76..c0554086c 100644--- a/src/schemas/vis-state-schema.js+++ b/src/schemas/vis-state-schema.js@@ -233,6 +233,7 @@ export const layerPropsV0 = {label: new LayerConfigSchemaV0({key: 'label'}),color: new LayerConfigSchemaV0({key: 'color'}),isVisible: new LayerConfigSchemaV0({key: 'isVisible'}),+ hidden: new LayerConfigSchemaV0({key: 'hidden'}),// convert visConfigvisConfig: new LayerVisConfigSchemaV0({key: 'visConfig'}),@@ -463,6 +464,7 @@ export const layerPropsV1 = {visConfig: new VisConfigSchemaV1({version: VERSIONS.v1}),+ hidden: false,textLabel: new TextLabelSchemaV1({version: VERSIONS.v1,key: 'textLabel'@@ -550,7 +552,7 @@ class InteractionSchemaV0 extends Schema {}}-const interactionPropsV1 = [...interactionPropsV0, 'coordinate'];+const interactionPropsV1 = [...interactionPropsV0, 'geocoder', 'coordinate'];class InteractionSchemaV1 extends Schema {key = 'interactionConfig';diff --git a/src/utils/interaction-utils.js b/src/utils/interaction-utils.jsindex 765921953..57382b15f 100644--- a/src/utils/interaction-utils.js+++ b/src/utils/interaction-utils.js@@ -24,7 +24,7 @@ import {ALL_FIELD_TYPES,TRIP_POINT_FIELDS} from 'constants/default-settings';-import {Messages, Crosshairs, CursorClick} from 'components/common/icons/index';+import {Messages, Crosshairs, CursorClick, Pin} from 'components/common/icons/index';export function getDefaultInteraction() {return {@@ -37,6 +37,13 @@ export function getDefaultInteraction() {fieldsToShow: {}}},+ geocoder: {+ id: 'geocoder',+ label: 'interactions.geocoder',+ enabled: false,+ iconComponent: Pin,+ position: null+ },brush: {id: 'brush',label: 'interactions.brush',diff --git a/test/browser/components/geocoder-panel-test.js b/test/browser/components/geocoder-panel-test.jsnew file mode 100644index 000000000..be84324b4--- /dev/null+++ b/test/browser/components/geocoder-panel-test.js@@ -0,0 +1,178 @@+// Copyright (c) 2020 Uber Technologies, Inc.+//+// Permission is hereby granted, free of charge, to any person obtaining a copy+// of this software and associated documentation files (the "Software"), to deal+// in the Software without restriction, including without limitation the rights+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+// copies of the Software, and to permit persons to whom the Software is+// furnished to do so, subject to the following conditions:+//+// The above copyright notice and this permission notice shall be included in+// all copies or substantial portions of the Software.+//+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN+// THE SOFTWARE.++import React from 'react';+import sinon from 'sinon';+import test from 'tape';+import {IntlWrapper, mountWithTheme} from 'test/helpers/component-utils';+import {GeocoderPanel} from 'components/geocoder-panel';++test('GeocoderPanel - render', t => {+ const enabled = true;+ const dispatch = sinon.spy();+ const mockGeoItem = {+ center: [0, 0],+ text: 'mock',+ bbox: [0, 0, 0, 0]+ };++ const mockGeoItemWithOutBbox = {+ center: [0, 0],+ text: 'mock'+ };++ const mockPayload = {+ datasets: [+ {+ data: {+ fields: [+ {+ name: 'lt',+ format: '',+ tableFieldIndex: 1,+ type: 'integer',+ analyzerType: 'INT'+ },+ {+ name: 'ln',+ format: '',+ tableFieldIndex: 2,+ type: 'integer',+ analyzerType: 'INT'+ },+ {+ name: 'icon',+ format: '',+ tableFieldIndex: 3,+ type: 'string',+ analyzerType: 'STRING'+ },+ {+ name: 'text',+ format: '',+ tableFieldIndex: 4,+ type: 'string',+ analyzerType: 'STRING'+ }+ ],+ rows: [[0, 0, 'place', 'mock']]+ },+ id: 'geocoder_dataset',+ info: {+ hidden: true,+ id: 'geocoder_dataset',+ label: 'geocoder_dataset'+ }+ }+ ],+ options: {+ keepExistingConfig: true+ },+ config: {+ version: 'v1',+ config: {+ visState: {+ layers: [+ {+ id: 'geocoder_layer',+ type: 'icon',+ config: {+ label: 'Geocoder Layer',+ color: [255, 0, 0],+ dataId: 'geocoder_dataset',+ columns: {+ lat: 'lt',+ lng: 'ln',+ icon: 'icon',+ label: 'text'+ },+ isVisible: true,+ hidden: true,+ visConfig: {+ radius: 80+ }+ }+ }+ ]+ }+ }+ }+ };++ // const onLayerClick = sinon.spy();+ let wrapper;++ t.doesNotThrow(() => {+ wrapper = mountWithTheme(+ <IntlWrapper>+ <GeocoderPanel+ isGeocoderEnabled={enabled}+ mapboxApiAccessToken="smoothie-the-cat"+ dispatch={dispatch}+ />+ </IntlWrapper>+ );+ }, 'Should render');++ t.equal(wrapper.find(GeocoderPanel).length, 1, 'Should display 1 GeoCoderPanel');+ t.equal(wrapper.find('Geocoder').length, 0, 'Should display 0 Geocoder because of invalid key');++ const instance = wrapper.find(GeocoderPanel).instance();++ instance.onSelected(null, mockGeoItem);+ t.deepEqual(+ dispatch.getCall(0).args,+ [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],+ 'Should be dispatching removeDataset action on onSelected'+ );+ t.deepEqual(+ dispatch.getCall(1).args,+ [{type: '@@kepler.gl/ADD_DATA_TO_MAP', payload: mockPayload}],+ 'Should be dispatching addDataToMap action on onSelected'+ );+ t.deepEqual(+ dispatch.getCall(2).args,+ [{type: '@@kepler.gl/FIT_BOUNDS', payload: mockGeoItem.bbox}],+ 'Should be dispatching fitBounds action on onSelected w/ bbox'+ );++ instance.onSelected(null, mockGeoItemWithOutBbox);+ t.deepEqual(+ dispatch.getCall(5).args,+ [{type: '@@kepler.gl/FIT_BOUNDS', payload: [-0.1, -0.1, 0.1, 0.1]}],+ 'Should be dispatching fitBounds action on onSelected w/o bbox'+ );++ instance.removeMarker();+ t.deepEqual(+ dispatch.getCall(6).args,+ [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],+ 'Should be dispatching removeDataset action on removeMarker'+ );++ instance.removeGeocoderDataset();+ t.deepEqual(+ dispatch.getCall(7).args,+ [{type: '@@kepler.gl/REMOVE_DATASET', key: 'geocoder_dataset'}],+ 'Should be dispatching removeDataset action on removeGeocoderDataset'+ );++ t.end();+});diff --git a/test/browser/components/index.js b/test/browser/components/index.jsindex 9dff049b5..720537e2e 100644--- a/test/browser/components/index.js+++ b/test/browser/components/index.js@@ -35,3 +35,4 @@ import './side-panel';import './common';import './editor';import './map-container-test';+import './geocoder-panel-test';diff --git a/test/browser/components/kepler-gl-test.js b/test/browser/components/kepler-gl-test.jsindex 8fda38d56..1176d7549 100644--- a/test/browser/components/kepler-gl-test.js+++ b/test/browser/components/kepler-gl-test.js@@ -34,7 +34,8 @@ import {MapContainerFactory,BottomWidgetFactory,ModalContainerFactory,- PlotContainerFactory+ PlotContainerFactory,+ GeocoderPanelFactory} from 'components';import NotificationPanelFactory from 'components/notification-panel';import {ActionTypes} from 'actions';@@ -46,6 +47,7 @@ const MapContainer = appInjector.get(MapContainerFactory);const BottomWidget = appInjector.get(BottomWidgetFactory);const ModalContainer = appInjector.get(ModalContainerFactory);const PlotContainer = appInjector.get(PlotContainerFactory);+const GeocoderPanel = appInjector.get(GeocoderPanelFactory);const NotificationPanel = appInjector.get(NotificationPanelFactory);const initialCoreState = coreReducer(@@ -86,6 +88,7 @@ test('Components -> KeplerGl -> Mount', t => {t.equal(wrapper.find(ModalContainer).length, 1, 'should render ModalContainer');t.equal(wrapper.find(PlotContainer).length, 0, 'should not render PlotContainer');t.equal(wrapper.find(NotificationPanel).length, 1, 'should render NotificationPanel');+ t.equal(wrapper.find(GeocoderPanel).length, 0, 'should not render GeocoderPanel');t.end();});@@ -127,6 +130,7 @@ test('Components -> KeplerGl -> Mount -> readOnly', t => {t.equal(wrapper.find(ModalContainer).length, 1, 'should render ModalContainer');t.equal(wrapper.find(PlotContainer).length, 0, 'should not render PlotContainer');t.equal(wrapper.find(NotificationPanel).length, 1, 'should render NotificationPanel');+ t.equal(wrapper.find(GeocoderPanel).length, 0, 'should not render GeocoderPanel');t.end();});@@ -168,6 +172,7 @@ test('Components -> KeplerGl -> Mount -> Plot', t => {t.equal(wrapper.find(ModalContainer).length, 1, 'should render ModalContainer');t.equal(wrapper.find(PlotContainer).length, 1, 'should render PlotContainer');t.equal(wrapper.find(NotificationPanel).length, 1, 'should render NotificationPanel');+ t.equal(wrapper.find(GeocoderPanel).length, 0, 'should not render GeocoderPanel');t.end();});@@ -209,6 +214,7 @@ test('Components -> KeplerGl -> Mount -> Split Maps', t => {t.equal(wrapper.find(ModalContainer).length, 1, 'should render ModalContainer');t.equal(wrapper.find(PlotContainer).length, 0, 'should render PlotContainer');t.equal(wrapper.find(NotificationPanel).length, 1, 'should render NotificationPanel');+ t.equal(wrapper.find(GeocoderPanel).length, 0, 'should not render GeocoderPanel');t.end();});diff --git a/test/fixtures/state-saved-v0.js b/test/fixtures/state-saved-v0.jsindex 0683d62e6..012347e2c 100644--- a/test/fixtures/state-saved-v0.js+++ b/test/fixtures/state-saved-v0.js@@ -1039,7 +1039,7 @@ mergedLayer0.config = {sizeScale: 'linear',sizeDomain: [0, 1],textLabel: [DEFAULT_TEXT_LABEL],-+ hidden: false,visConfig: {radius: 270.4,opacity: 0.8,@@ -1107,6 +1107,7 @@ mergedLayer1.config = {color: DEFAULT_COLOR_UI,colorRange: DEFAULT_COLOR_UI},+ hidden: false,visConfig: {opacity: 0.41,thickness: 2,@@ -1175,6 +1176,7 @@ mergedLayer2.config = {color: DEFAULT_COLOR_UI,colorRange: DEFAULT_COLOR_UI},+ hidden: false,visConfig: {radius: 10,opacity: 0.8,@@ -1224,6 +1226,7 @@ mergedLayer3.config = {fieldIdx: 2}},+ hidden: false,isVisible: true,colorField: {name: 'int_range',@@ -1285,6 +1288,7 @@ mergedLayer4.config = {},highlightColor: [252, 242, 26, 255],isConfigActive: false,+ hidden: false,isVisible: true,colorField: {name: 'ID',diff --git a/test/fixtures/state-saved-v1-1.js b/test/fixtures/state-saved-v1-1.jsindex e0f46c95c..6c29aff25 100644--- a/test/fixtures/state-saved-v1-1.js+++ b/test/fixtures/state-saved-v1-1.js@@ -873,6 +873,7 @@ mergedLayer0.config = {value: 'simplified_shape_v2'}},+ hidden: false,isVisible: true,isConfigActive: false,highlightColor: [252, 242, 26, 255],@@ -2709,6 +2710,7 @@ mergedLayer1.config = {tableFieldIndex: 13,analyzerType: 'FLOAT'},+ hidden: false,sizeScale: 'linear',sizeDomain: [0.970877074, 1],textLabel: [DEFAULT_TEXT_LABEL],diff --git a/test/fixtures/state-saved-v1-3.js b/test/fixtures/state-saved-v1-3.jsindex 0f118f6f9..f53bc155a 100644--- a/test/fixtures/state-saved-v1-3.js+++ b/test/fixtures/state-saved-v1-3.js@@ -355,6 +355,7 @@ mergedLayer0.config = {value: null}},+ hidden: false,isVisible: true,colorField: {name: 'deliver_radius',@@ -431,6 +432,7 @@ mergedLayer1.config = {fieldIdx: 2}},+ hidden: false,isVisible: true,colorField: null,colorDomain: [0, 1],diff --git a/test/fixtures/state-saved-v1-4.js b/test/fixtures/state-saved-v1-4.jsindex fc49b729e..a23a6af09 100644--- a/test/fixtures/state-saved-v1-4.js+++ b/test/fixtures/state-saved-v1-4.js@@ -207,6 +207,7 @@ mergedLayer0.config = {value: null}},+ hidden: false,isVisible: true,colorField: null,colorScale: 'quantile',diff --git a/test/fixtures/state-saved-v1-5.js b/test/fixtures/state-saved-v1-5.jsindex d8544c961..e59e39467 100644--- a/test/fixtures/state-saved-v1-5.js+++ b/test/fixtures/state-saved-v1-5.js@@ -255,6 +255,7 @@ mergedLayer0.config = {label: 'Trip Data',color: [0, 0, 0],columns: {geojson: {value: '_geojson', fieldIdx: 0}},+ hidden: false,isVisible: true,isConfigActive: false,highlightColor: [252, 242, 26, 255],diff --git a/test/fixtures/test-csv-data.js b/test/fixtures/test-csv-data.jsindex 66c8f8d93..69a4dcf31 100644--- a/test/fixtures/test-csv-data.js+++ b/test/fixtures/test-csv-data.js@@ -76,6 +76,7 @@ export const config = {lng: 'gps_data.lng',altitude: null},+ hidden: false,isVisible: true,visConfig: {radius: 39.2,@@ -137,6 +138,7 @@ export const config = {lat: 'gps_data.lat',lng: 'gps_data.lng'},+ hidden: false,isVisible: true,visConfig: {opacity: 0.8,@@ -186,6 +188,9 @@ export const config = {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',diff --git a/test/fixtures/test-hex-id-data.js b/test/fixtures/test-hex-id-data.jsindex 780bd9d15..3c221edcb 100644--- a/test/fixtures/test-hex-id-data.js+++ b/test/fixtures/test-hex-id-data.js@@ -77,6 +77,7 @@ export const hexIdDataConfig = {columns: {hex_id: 'hex_id'},+ hidden: false,isVisible: true,visConfig: {opacity: 0.8,@@ -125,6 +126,9 @@ export const hexIdDataConfig = {brush: {size: 0.5,enabled: false+ },+ geocoder: {+ enabled: false}},layerBlending: 'normal',@@ -336,6 +340,7 @@ mergedH3Layer.config = {fieldIdx: 0}},+ hidden: false,isVisible: true,highlightColor: [252, 242, 26, 255],isConfigActive: false,diff --git a/test/fixtures/test-trip-data.js b/test/fixtures/test-trip-data.jsindex 54de3eb5a..aa87a96a7 100644--- a/test/fixtures/test-trip-data.js+++ b/test/fixtures/test-trip-data.js@@ -139,6 +139,7 @@ export const config = {lat: 'pickup_latitude',lng: 'pickup_longitude'},+ hidden: false,isVisible: true}},@@ -150,6 +151,7 @@ export const config = {lat: 'pickup_latitude',lng: 'pickup_longitude'},+ hidden: false,isVisible: true,visConfig: {colorRange: {@@ -197,6 +199,7 @@ export const config = {lat1: 'dropoff_latitude',lng1: 'dropoff_longitude'},+ hidden: false,isVisible: true}},@@ -210,6 +213,7 @@ export const config = {lat: 'pickup_latitude',lng: 'pickup_longitude'},+ hidden: false,isVisible: true,visConfig: {opacity: 0.76,diff --git a/test/helpers/mock-state.js b/test/helpers/mock-state.jsindex f039604b3..37448e3c7 100644--- a/test/helpers/mock-state.js+++ b/test/helpers/mock-state.js@@ -386,6 +386,7 @@ export const expectedSavedLayer0 = {lat: 'gps_data.lat',lng: 'gps_data.lng'},+ hidden: false,isVisible: true,visConfig: {opacity: DEFAULT_LAYER_OPACITY,@@ -422,6 +423,7 @@ export const expectedLoadedLayer0 = {lat: 'gps_data.lat',lng: 'gps_data.lng'},+ hidden: false,isVisible: true,visConfig: {opacity: DEFAULT_LAYER_OPACITY,@@ -467,6 +469,7 @@ export const expectedSavedLayer1 = {color: [255, 0, 0]}],+ hidden: false,isVisible: true,visConfig: {radius: 10,@@ -511,6 +514,7 @@ export const expectedLoadedLayer1 = {lng: 'gps_data.lng',altitude: null},+ hidden: false,isVisible: true,visConfig: {radius: 10,@@ -561,6 +565,7 @@ export const expectedSavedLayer2 = {columns: {geojson: '_geojson'},+ hidden: false,isVisible: true,visConfig: {opacity: DEFAULT_LAYER_OPACITY,@@ -605,6 +610,7 @@ export const expectedLoadedLayer2 = {columns: {geojson: '_geojson'},+ hidden: false,isVisible: true,visConfig: {opacity: DEFAULT_LAYER_OPACITY,@@ -657,6 +663,7 @@ export const expectedSavedTripLayer = {columns: {geojson: '_geojson'},+ hidden: false,isVisible: true,visConfig: {opacity: DEFAULT_LAYER_OPACITY,diff --git a/test/node/reducers/vis-state-test.js b/test/node/reducers/vis-state-test.jsindex 482cd5c84..fd25b1a4a 100644--- a/test/node/reducers/vis-state-test.js+++ b/test/node/reducers/vis-state-test.js@@ -2422,7 +2422,8 @@ test('#visStateReducer -> REMOVE_DATASET w filter and layer', t => {}},brush: oldState.interactionConfig.brush,- coordinate: oldState.interactionConfig.coordinate+ coordinate: oldState.interactionConfig.coordinate,+ geocoder: oldState.interactionConfig.geocoder},editingDataset: oldState.editingDataset,layerBlending: oldState.layerBlending,@@ -2639,7 +2640,8 @@ test('#visStateReducer -> SPLIT_MAP: REMOVE_DATASET', t => {}},brush: oldState.interactionConfig.brush,- coordinate: oldState.interactionConfig.coordinate+ coordinate: oldState.interactionConfig.coordinate,+ geocoder: oldState.interactionConfig.geocoder},splitMaps: [{layers: {'point-0': false}}, {layers: {'point-0': true}}],editingDataset: oldState.editingDataset,@@ -2845,6 +2847,10 @@ test('#visStateReducer -> INTERACTION_CONFIG_CHANGE', t => {tooltip: {...defaultInteractionConfig.tooltip,enabled: false+ },+ geocoder: {+ ...defaultInteractionConfig.geocoder,+ enabled: false}};diff --git a/test/node/schemas/vis-state-schema-test.js b/test/node/schemas/vis-state-schema-test.jsindex 3bc65ff79..b15ffc566 100644--- a/test/node/schemas/vis-state-schema-test.js+++ b/test/node/schemas/vis-state-schema-test.js@@ -141,6 +141,9 @@ test('#visStateSchema -> v1 -> save load interaction', t => {},coordinate: {enabled: false+ },+ geocoder: {+ enabled: false}};diff --git a/yarn.lock b/yarn.lockindex 4df8ae338..e2363ba08 100644--- a/yarn.lock+++ b/yarn.lock@@ -6216,7 +6216,7 @@ es6-error@^4.0.1:resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d"integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==-es6-promise@^4.0.3:+es6-promise@^4.0.3, es6-promise@^4.0.5:version "4.2.8"resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a"integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==@@ -10235,6 +10235,14 @@ mapbox-gl@^1.0.0:tinyqueue "^2.0.0"vt-pbf "^3.1.1"+mapbox@^1.0.0-beta10:+ version "1.0.0-beta10"+ resolved "https://registry.yarnpkg.com/mapbox/-/mapbox-1.0.0-beta10.tgz#037561bcb95cbdc066d1dff7e2ce1d6c8539cb8e"+ integrity sha1-A3VhvLlcvcBm0d/34s4dbIU5y44=+ dependencies:+ es6-promise "^4.0.5"+ rest "^2.0.0"+markdown-escapes@^1.0.0:version "1.0.4"resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535"@@ -12698,6 +12706,14 @@ react-map-gl@^5.0.3:react-virtualized-auto-sizer "^1.0.2"viewport-mercator-project "^6.2.3 || ^7.0.1"+react-mapbox-gl-geocoder@^1.1.0:+ version "1.1.0"+ resolved "https://registry.yarnpkg.com/react-mapbox-gl-geocoder/-/react-mapbox-gl-geocoder-1.1.0.tgz#f07e27a1329db711ec5843fbf1b78dbdc5930c9a"+ integrity sha512-U8fVUlj7Sb19KOgkKvfr3MPuqiGZ+ldHwwfo4BxBv7cyr397PQ/0o2XiC/Nz4PvN7dbIFHz7JfuVaq/MFZ5oHw==+ dependencies:+ mapbox "^1.0.0-beta10"+ viewport-mercator-project "^6.0.0"+react-markdown@^4.0.6:version "4.3.1"resolved "https://registry.yarnpkg.com/react-markdown/-/react-markdown-4.3.1.tgz#39f0633b94a027445b86c9811142d05381300f2f"@@ -13565,6 +13581,11 @@ resolve@~1.4.0:dependencies:path-parse "^1.0.5"+rest@^2.0.0:+ version "2.0.0"+ resolved "https://registry.yarnpkg.com/rest/-/rest-2.0.0.tgz#6dfadf66a405c49cfbd5b4bd25b59fd29cd861bc"+ integrity sha1-bfrfZqQFxJz71bS9JbWf0pzYYbw=+restore-cursor@^2.0.0:version "2.0.0"resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"