Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] Export more utils (#1317)

Shan He6c48c4225edc
diff --git a/src/components/common/styled-components.js b/src/components/common/styled-components.js
index 34ec7f128..08b00b3aa 100644
--- a/src/components/common/styled-components.js
+++ b/src/components/common/styled-components.js
@@ -500,6 +500,7 @@ export const StyledAttrbution = styled.div.attrs({
justify-content: flex-end;
align-items: center;
color: ${props => props.theme.labelColor};
+ margin-bottom: -4px;
a.mapboxgl-ctrl-logo {
width: 72px;
diff --git a/src/components/index.js b/src/components/index.js
index ce6214e09..3d51d5ad4 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -24,7 +24,7 @@ import VisConfigSliderFactory from './side-panel/layer-panel/vis-config-slider';
import VisConfigSwitchFactory from './side-panel/layer-panel/vis-config-switch';
import LayerConfigGroupFactory from './side-panel/layer-panel/layer-config-group';
import {ChannelByValueSelectorFactory} from './side-panel/layer-panel/layer-configurator';
-import FieldSelectorFactory from './common/field-selector';
+import FieldSelectorFactory, {FieldListItemFactoryFactory} from './common/field-selector';
import FieldTokenFactory from './common/field-token';
import PanelHeaderActionFactory from './side-panel/panel-header-action';
import {appInjector} from './container';
@@ -117,7 +117,6 @@ export {default as RangePlotFactory} from './common/range-plot';
export {default as HistogramPlotFactory} from './common/histogram-plot';
export {default as LineChartFactory} from './common/line-chart';
export {default as RangeBrushFactory} from './common/range-brush';
-export {FieldListItemFactoryFactory} from './common/field-selector';
export {default as TimeSliderMarkerFactory} from './common/time-slider-marker';
export {default as InfoHelperFactory} from 'components/common/info-helper';
@@ -176,6 +175,10 @@ export {
LayerColorSelector
} from './side-panel/layer-panel/layer-configurator';
+// map components
+export {default as MapLegend} from 'components/map/map-legend'
+
+
export * from './common/styled-components';
import * as Icons from './common/icons';
export {Icons};
@@ -190,6 +193,7 @@ export const ChannelByValueSelector = appInjector.get(ChannelByValueSelectorFact
export const FieldSelector = appInjector.get(FieldSelectorFactory);
export const FieldToken = appInjector.get(FieldTokenFactory);
export const PanelHeaderAction = appInjector.get(PanelHeaderActionFactory);
+export const FieldListItemFactory = appInjector.get(FieldListItemFactoryFactory);
export {
appInjector,
@@ -198,5 +202,9 @@ export {
VisConfigSliderFactory,
VisConfigSwitchFactory,
LayerConfigGroupFactory,
- ChannelByValueSelectorFactory
+ ChannelByValueSelectorFactory,
+ FieldListItemFactoryFactory
};
+
+// Context
+export {default as KeplerGlContext, RootContext} from 'components/context';
diff --git a/src/components/kepler-gl.js b/src/components/kepler-gl.js
index 3c8243ea7..1c5a32c41 100644
--- a/src/components/kepler-gl.js
+++ b/src/components/kepler-gl.js
@@ -132,6 +132,9 @@ function KeplerGlFactory(
this._validateMapboxToken();
this._loadMapStyle(this.props.mapStyles);
this._handleResize(this.props);
+ if (typeof this.props.onKeplerGlInitialized === 'function') {
+ this.props.onKeplerGlInitialized();
+ }
}
componentDidUpdate(prevProps) {
diff --git a/src/layers/base-layer.js b/src/layers/base-layer.js
index bc4673d67..05b54a651 100644
--- a/src/layers/base-layer.js
+++ b/src/layers/base-layer.js
@@ -1008,7 +1008,7 @@ export default class Layer {
highlightColor: this.config.highlightColor,
// data filtering
extensions: [dataFilterExtension],
- filterRange: gpuFilter.filterRange
+ filterRange: gpuFilter ? gpuFilter.filterRange : undefined
};
}
diff --git a/src/layers/index.js b/src/layers/index.js
index b2a36c5a6..a1372d6b0 100644
--- a/src/layers/index.js
+++ b/src/layers/index.js
@@ -68,3 +68,5 @@ export const LayerClasses = {
[LAYER_TYPES.trip]: TripLayer,
[LAYER_TYPES.s2]: S2GeometryLayer
};
+
+export {LAYER_VIS_CONFIGS} from './layer-factory';
diff --git a/src/layers/types.js b/src/layers/types.js
index 3d00c25e8..98e5869bc 100644
--- a/src/layers/types.js
+++ b/src/layers/types.js
@@ -1,3 +1,23 @@
+// 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 keyMirror from 'keymirror';
export const LAYER_TYPES = keyMirror({
diff --git a/src/processors/index.js b/src/processors/index.js
index 1e4693b8a..b7ddcd241 100644
--- a/src/processors/index.js
+++ b/src/processors/index.js
@@ -31,6 +31,6 @@ export {
} from './data-processor';
// File Handlers
-export {readFileInBatches, processFileData, filesToDataPayload} from './file-handler';
+export {readFileInBatches, processFileData, filesToDataPayload, isKeplerGlMap} from './file-handler';
export {Processors as default} from './data-processor';
diff --git a/src/utils/dataset-utils.js b/src/utils/dataset-utils.js
index 4716adcd2..8a6d762ac 100644
--- a/src/utils/dataset-utils.js
+++ b/src/utils/dataset-utils.js
@@ -54,7 +54,7 @@ function* generateColor() {
export const datasetColorMaker = generateColor();
/** @type {typeof import('./dataset-utils').getNewDatasetColor} */
-function getNewDatasetColor(datasets) {
+export function getNewDatasetColor(datasets) {
const presetColors = datasetColors.map(String);
const usedColors = uniq(Object.values(datasets).map(d => String(d.color))).filter(c =>
presetColors.includes(c)
diff --git a/utils.js b/utils.js
new file mode 100644
index 000000000..27f3cbc46
--- /dev/null
+++ b/utils.js
@@ -0,0 +1,21 @@
+// 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.
+
+module.exports = require('./dist/utils');