Skip to content

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

fix: Open map control and geocoder for extension (#2103)

Igor Dykhta47cc281cccff
diff --git a/package.json b/package.json
index 168bd781c..eb0a14d27 100644
--- a/package.json
+++ b/package.json
@@ -221,6 +221,7 @@
"@deck.gl/test-utils": "^8.6.0",
"@luma.gl/test-utils": "^8.5.10",
"browserslist": "^4.17.0",
+ "caniuse-lite": "^1.0.30001361",
"d3-array": "^2.8.0",
"d3-scale": "^3.2.3",
"dot-prop": "6.0.0",
@@ -229,8 +230,7 @@
"lodash": "4.17.19",
"minimist": "1.2.3",
"node-fetch": "2.6.1",
- "tough-cookie": "4.0.0",
- "caniuse-lite": "^1.0.30001361"
+ "tough-cookie": "4.0.0"
},
"peerDependencies": {
"react": ">=16.3",
diff --git a/src/components/src/geocoder-panel.tsx b/src/components/src/geocoder-panel.tsx
index 75dd841a9..0dcc46974 100644
--- a/src/components/src/geocoder-panel.tsx
+++ b/src/components/src/geocoder-panel.tsx
@@ -20,6 +20,7 @@
import React, {Component, ComponentType} from 'react';
import styled from 'styled-components';
+import classnames from 'classnames';
import {processRowObject} from '@kepler.gl/processors';
import {FlyToInterpolator} from '@deck.gl/core';
import KeplerGlSchema from '@kepler.gl/schemas';
@@ -33,7 +34,7 @@ import {
GEOCODER_ICON_COLOR,
GEOCODER_ICON_SIZE
} from '@kepler.gl/constants';
-import {MapState, Viewport} from '@kepler.gl/types';
+import {MapState, UiState, Viewport} from '@kepler.gl/types';
const ICON_LAYER = {
id: GEOCODER_LAYER_ID,
@@ -114,6 +115,7 @@ export function getUpdateVisDataPayload(lat, lon, text) {
interface GeocoderPanelProps {
isGeocoderEnabled: boolean;
mapState: MapState;
+ uiState: UiState;
mapboxApiAccessToken: string;
updateVisData: Function;
removeDataset: Function;
@@ -121,6 +123,8 @@ interface GeocoderPanelProps {
transitionDuration?: number;
width?: number;
+ appWidth: number;
+ className?: string;
}
export default function GeocoderPanelFactory(): ComponentType<GeocoderPanelProps> {
@@ -175,10 +179,10 @@ export default function GeocoderPanelFactory(): ComponentType<GeocoderPanelProps
};
render() {
- const {isGeocoderEnabled, mapboxApiAccessToken, width} = this.props;
+ const {isGeocoderEnabled, mapboxApiAccessToken, width, className} = this.props;
return (
<StyledGeocoderPanel
- className="geocoder-panel"
+ className={classnames('geocoder-panel', className)}
width={width}
style={{display: isGeocoderEnabled ? 'block' : 'none'}}
>
diff --git a/src/components/src/kepler-gl.tsx b/src/components/src/kepler-gl.tsx
index a8f2b1363..46a5ecfa8 100644
--- a/src/components/src/kepler-gl.tsx
+++ b/src/components/src/kepler-gl.tsx
@@ -238,13 +238,18 @@ export const modalContainerSelector = (props: KeplerGLProps, rootNode) => ({
onExportToCloudError: props.onExportToCloudError
});
-export const geoCoderPanelSelector = (props: KeplerGLProps) => ({
+export const geoCoderPanelSelector = (
+ props: KeplerGLProps,
+ dimensions: {width: number; height: number}
+) => ({
isGeocoderEnabled: props.visState.interactionConfig.geocoder.enabled,
mapboxApiAccessToken: props.mapboxApiAccessToken,
mapState: props.mapState,
+ uiState: props.uiState,
updateVisData: props.visStateActions.updateVisData,
removeDataset: props.visStateActions.removeDataset,
- updateMap: props.mapStateActions.updateMap
+ updateMap: props.mapStateActions.updateMap,
+ appWidth: dimensions.width
});
export const notificationPanelSelector = (props: KeplerGLProps) => ({
@@ -456,7 +461,7 @@ function KeplerGlFactory(
const plotContainerFields = plotContainerSelector(this.props);
const bottomWidgetFields = bottomWidgetSelector(this.props, theme);
const modalContainerFields = modalContainerSelector(this.props, this.root.current);
- const geoCoderPanelFields = geoCoderPanelSelector(this.props);
+ const geoCoderPanelFields = geoCoderPanelSelector(this.props, dimensions);
const notificationPanelFields = notificationPanelSelector(this.props);
const mapContainers = !isSplit
diff --git a/src/components/src/map-container.tsx b/src/components/src/map-container.tsx
index 409d1bd92..99527cccb 100644
--- a/src/components/src/map-container.tsx
+++ b/src/components/src/map-container.tsx
@@ -757,7 +757,8 @@ export default function MapContainerFactory(
index,
primary,
bottomMapContainerProps,
- topMapContainerProps
+ topMapContainerProps,
+ theme
} = this.props;
const {layers, datasets, editor, interactionConfig} = visState;
@@ -795,7 +796,11 @@ export default function MapContainerFactory(
mapControls={mapControls}
readOnly={this.props.readOnly}
scale={mapState.scale || 1}
- top={interactionConfig.geocoder && interactionConfig.geocoder.enabled ? 52 : 0}
+ top={
+ interactionConfig.geocoder && interactionConfig.geocoder.enabled
+ ? theme.mapControlTop
+ : 0
+ }
editor={editor}
locale={locale}
onTogglePerspective={mapStateActions.togglePerspective}
diff --git a/src/styles/src/base.ts b/src/styles/src/base.ts
index e7da75f56..a75e65180 100644
--- a/src/styles/src/base.ts
+++ b/src/styles/src/base.ts
@@ -359,6 +359,9 @@ export const geocoderTop = 20;
export const geocoderRight = 12;
export const geocoderInputHeight = 36;
+// Map Control
+export const mapControlTop = 52;
+
// Plot
export const rangeBrushBgd = '#3A414C';
export const histogramFillInRange = activeColor;
@@ -1431,6 +1434,9 @@ export const theme = {
geocoderRight,
geocoderInputHeight,
+ // Map Control
+ mapControlTop,
+
// Plot
rangeBrushBgd,
histogramFillInRange,
diff --git a/test/browser/components/geocoder-panel-test.js b/test/browser/components/geocoder-panel-test.js
index bca3d944a..33f5aa892 100644
--- a/test/browser/components/geocoder-panel-test.js
+++ b/test/browser/components/geocoder-panel-test.js
@@ -26,6 +26,8 @@ import {IntlWrapper, mountWithTheme} from 'test/helpers/component-utils';
import {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 MAPBOX_TOKEN = process.env.MapboxAccessToken;
@@ -42,6 +44,8 @@ test('GeocoderPanel - render', t => {
height: 800
};
+ const mockUiState = InitialState.uiState;
+
const mockGeoItem = {
center: [1, 55],
text: 'mock',
@@ -149,6 +153,7 @@ test('GeocoderPanel - render', t => {
isGeocoderEnabled={enabled}
mapboxApiAccessToken={MAPBOX_TOKEN}
mapState={mockMapState}
+ uiState={mockUiState}
updateVisData={updateVisData}
removeDataset={removeDataset}
updateMap={updateMap}