Skip to content

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

[Enhancement] Hexbin Layer: smaller radius step and dynamic hover (#310)

Shan He15f8eb5e84ba
diff --git a/src/layers/hexagon-layer/hexagon-layer.js b/src/layers/hexagon-layer/hexagon-layer.js
index 5b7198749..f47f820d9 100644
--- a/src/layers/hexagon-layer/hexagon-layer.js
+++ b/src/layers/hexagon-layer/hexagon-layer.js
@@ -23,6 +23,7 @@ import AggregationLayer from '../aggregation-layer';
import EnhancedHexagonLayer from 'deckgl-layers/hexagon-layer/enhanced-hexagon-layer';
import {hexagonToPolygonGeo} from './hexagon-utils';
import HexagonLayerIcon from './hexagon-layer-icon';
+import {clamp} from 'utils/data-utils';
export const hexagonVisConfigs = {
opacity: 'opacity',
@@ -123,7 +124,7 @@ export default class HexagonLayer extends AggregationLayer {
)
],
getLineColor: this.config.highlightColor,
- lineWidthScale: 8 * zoomFactor
+ lineWidthScale: clamp([1, 100], radius * 0.1 * zoomFactor)
})
]
: [])
diff --git a/src/layers/layer-factory.js b/src/layers/layer-factory.js
index 456e32967..fa6a670f9 100644
--- a/src/layers/layer-factory.js
+++ b/src/layers/layer-factory.js
@@ -215,8 +215,8 @@ export const LAYER_VIS_CONFIGS = {
defaultValue: 1,
label: 'World Unit Size',
isRanged: false,
- range: [0.01, 500],
- step: 0.01,
+ range: [0, 500],
+ step: 0.0001,
group: PROPERTY_GROUPS.cell,
property: 'worldUnitSize'
},
diff --git a/src/utils/data-utils.js b/src/utils/data-utils.js
index 433cd59cd..6fa77101d 100644
--- a/src/utils/data-utils.js
+++ b/src/utils/data-utils.js
@@ -94,6 +94,10 @@ export function getLatLngBounds(points, idx, limit) {
];
}
+export function clamp([min, max], val) {
+ return val <= min ? min : val >= max ? max : val;
+};
+
export function getSampleData(data, sampleSize = 500) {
const sampleStep = Math.max(Math.floor(data.length / sampleSize), 1);
const output = [];