Skip to content

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

[Feat] add zoom to coordinate tooltip (#1179)

Shan Hef71e93650a94
diff --git a/src/components/map-container.js b/src/components/map-container.js
index e632f1eec..6cc116fc1 100644
--- a/src/components/map-container.js
+++ b/src/components/map-container.js
@@ -287,28 +287,31 @@ export default function MapContainerFactory(MapPopover, MapControl, Editor) {
layerHoverProp.compareType = interactionConfig.tooltip.config.compareType;
}
}
+ const commonProp = {
+ onClose: this._onCloseMapPopover,
+ mapW: mapState.width,
+ mapH: mapState.height,
+ zoom: mapState.zoom
+ };
+
return (
<div>
{hasTooltip && (
<MapPopover
{...pinnedPosition}
+ {...commonProp}
layerHoverProp={layerPinnedProp}
coordinate={interactionConfig.coordinate.enabled && (pinned || {}).coordinate}
frozen={Boolean(hasTooltip)}
- onClose={this._onCloseMapPopover}
- mapW={mapState.width}
- mapH={mapState.height}
isBase={compareMode}
/>
)}
{hasComparisonTooltip && (
<MapPopover
{...position}
+ {...commonProp}
layerHoverProp={layerHoverProp}
coordinate={interactionConfig.coordinate.enabled && coordinate}
- onClose={this._onCloseMapPopover}
- mapW={mapState.width}
- mapH={mapState.height}
/>
)}
</div>
diff --git a/src/components/map/coordinate-info.js b/src/components/map/coordinate-info.js
index db3e7e076..bf6af4e10 100644
--- a/src/components/map/coordinate-info.js
+++ b/src/components/map/coordinate-info.js
@@ -26,9 +26,10 @@ import {StyledLayerName} from './layer-hover-info';
// 6th decimal is worth up to 0.11 m
// https://gis.stackexchange.com/questions/8650/measuring-accuracy-of-latitude-and-longitude
const DECIMAL = 6;
+const DECIMAL_Z = 1;
const CoordinateInfoFactory = () => {
- const CoordinateInfo = ({coordinate}) => (
+ const CoordinateInfo = ({coordinate, zoom}) => (
<div>
<StyledLayerName className="map-popover__layer-name">
<CursorClick height="12px" />
@@ -38,7 +39,8 @@ const CoordinateInfoFactory = () => {
<tbody>
<tr className="row">
<td className="row__value">{preciseRound(coordinate[1], DECIMAL)},</td>
- <td className="row__value">{preciseRound(coordinate[0], DECIMAL)}</td>
+ <td className="row__value">{preciseRound(coordinate[0], DECIMAL)},</td>
+ <td className="row__value">{preciseRound(zoom, DECIMAL_Z)}z</td>
</tr>
</tbody>
</table>
diff --git a/src/components/map/map-popover.js b/src/components/map/map-popover.js
index aab1fe928..da2972456 100644
--- a/src/components/map/map-popover.js
+++ b/src/components/map/map-popover.js
@@ -114,6 +114,7 @@ export default function MapPopoverFactory(LayerHoverInfo, CoordinateInfo) {
frozen: PropTypes.bool,
x: PropTypes.number,
y: PropTypes.number,
+ z: PropTypes.number,
mapW: PropTypes.number.isRequired,
mapH: PropTypes.number.isRequired,
onClose: PropTypes.func.isRequired,
@@ -183,7 +184,7 @@ export default function MapPopoverFactory(LayerHoverInfo, CoordinateInfo) {
};
render() {
- const {x, y, frozen, coordinate, layerHoverProp, isBase} = this.props;
+ const {x, y, frozen, coordinate, layerHoverProp, isBase, zoom} = this.props;
const {isLeft} = this.state;
const style = Number.isFinite(x) && Number.isFinite(y) ? this._getPosition(x, y, isLeft) : {};
@@ -221,7 +222,7 @@ export default function MapPopoverFactory(LayerHoverInfo, CoordinateInfo) {
)}
</div>
) : null}
- {Array.isArray(coordinate) && <CoordinateInfo coordinate={coordinate} />}
+ {Array.isArray(coordinate) && <CoordinateInfo coordinate={coordinate} zoom={zoom} />}
{layerHoverProp && <LayerHoverInfo {...layerHoverProp} />}
</StyledMapPopover>
</ErrorBoundary>