@carto/kepler.gl 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.js +10 -1
- package/dist/components/map/map-popover.js +20 -2
- package/dist/components/map-container.js +14 -1
- package/dist/components/side-panel/layer-panel/layer-configurator.js +8 -3
- package/dist/components/side-panel/layer-panel/layer-visibility-by-zoom.js +106 -0
- package/dist/constants/default-settings.js +8 -3
- package/dist/layers/base-layer.js +11 -1
- package/dist/localization/ca.js +4 -1
- package/dist/localization/cn.js +4 -1
- package/dist/localization/en.js +4 -1
- package/dist/localization/es.js +4 -1
- package/dist/localization/fi.js +4 -1
- package/dist/localization/ja.js +4 -1
- package/dist/localization/pt.js +4 -1
- package/dist/localization/ru.js +4 -1
- package/dist/reducers/vis-state-merger.js +3 -2
- package/dist/schemas/vis-state-schema.js +5 -1
- package/package.json +1 -1
- package/src/components/index.js +1 -0
- package/src/components/map/map-popover.js +15 -1
- package/src/components/map-container.js +14 -0
- package/src/components/side-panel/layer-panel/layer-configurator.js +6 -2
- package/src/components/side-panel/layer-panel/layer-visibility-by-zoom.js +120 -0
- package/src/constants/default-settings.js +5 -0
- package/src/layers/base-layer.js +10 -3
- package/src/layers/index.d.ts +1 -0
- package/src/localization/ca.js +3 -0
- package/src/localization/cn.js +3 -0
- package/src/localization/en.js +3 -0
- package/src/localization/es.js +3 -0
- package/src/localization/fi.js +3 -0
- package/src/localization/ja.js +3 -0
- package/src/localization/pt.js +3 -0
- package/src/localization/ru.js +3 -0
- package/src/reducers/vis-state-merger.js +2 -1
- package/src/schemas/schema-manager.d.ts +1 -0
- package/src/schemas/vis-state-schema.js +2 -0
- package/umd/keplergl.min.js +31 -31
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Copyright (c) 2022 Uber Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
// of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
// in the Software without restriction, including without limitation the rights
|
|
6
|
+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
// furnished to do so, subject to the following conditions:
|
|
9
|
+
//
|
|
10
|
+
// The above copyright notice and this permission notice shall be included in
|
|
11
|
+
// all copies or substantial portions of the Software.
|
|
12
|
+
//
|
|
13
|
+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
// THE SOFTWARE.
|
|
20
|
+
|
|
21
|
+
import React, {useCallback} from 'react';
|
|
22
|
+
import PropTypes from 'prop-types';
|
|
23
|
+
import styled from 'styled-components';
|
|
24
|
+
import RangeSliderFactory from 'components/common/range-slider';
|
|
25
|
+
import {PanelLabel, SidePanelSection} from 'components/common/styled-components';
|
|
26
|
+
import {FormattedMessage} from 'localization';
|
|
27
|
+
import {ZOOM_LEVEL_LIMITS} from 'constants/default-settings';
|
|
28
|
+
|
|
29
|
+
const SliderWrapper = styled.div`
|
|
30
|
+
position: relative;
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const TopRow = styled.div`
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
LayerVisibilityByZoomFactory.deps = [RangeSliderFactory];
|
|
39
|
+
|
|
40
|
+
function LayerVisibilityByZoomFactory(RangeSlider) {
|
|
41
|
+
const LayerVisibilityByZoom = ({
|
|
42
|
+
updateLayerConfig,
|
|
43
|
+
layer,
|
|
44
|
+
rangeMinValue,
|
|
45
|
+
rangeMaxValue,
|
|
46
|
+
iconComponent
|
|
47
|
+
}) => {
|
|
48
|
+
const {config} = layer;
|
|
49
|
+
const minLimit = rangeMinValue || ZOOM_LEVEL_LIMITS.min;
|
|
50
|
+
const maxLimit = rangeMaxValue || ZOOM_LEVEL_LIMITS.max;
|
|
51
|
+
|
|
52
|
+
const [zoomMin, setZoomMin] = React.useState(
|
|
53
|
+
config.visibilityByZoom?.min
|
|
54
|
+
? config.visibilityByZoom?.min < minLimit
|
|
55
|
+
? minLimit
|
|
56
|
+
: config.visibilityByZoom?.min
|
|
57
|
+
: minLimit
|
|
58
|
+
);
|
|
59
|
+
const [zoomMax, setZoomMax] = React.useState(
|
|
60
|
+
config.visibilityByZoom?.max
|
|
61
|
+
? config.visibilityByZoom?.max > maxLimit
|
|
62
|
+
? maxLimit
|
|
63
|
+
: config.visibilityByZoom?.max
|
|
64
|
+
: maxLimit
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const _onChange = useCallback(
|
|
68
|
+
val => {
|
|
69
|
+
setZoomMin(val[0]);
|
|
70
|
+
setZoomMax(val[1]);
|
|
71
|
+
updateLayerConfig({visibilityByZoom: {min: val[0], max: val[1]}});
|
|
72
|
+
},
|
|
73
|
+
[updateLayerConfig]
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const IconElement = () => iconComponent || null;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div>
|
|
80
|
+
<SidePanelSection>
|
|
81
|
+
<div className="layer-visibility__zoom">
|
|
82
|
+
<TopRow>
|
|
83
|
+
<PanelLabel>
|
|
84
|
+
<FormattedMessage id={'layerVisibility.title'} />{' '}
|
|
85
|
+
<IconElement data-test="icon-help-button" />
|
|
86
|
+
</PanelLabel>
|
|
87
|
+
</TopRow>
|
|
88
|
+
<SliderWrapper>
|
|
89
|
+
<RangeSlider
|
|
90
|
+
range={[
|
|
91
|
+
rangeMinValue || ZOOM_LEVEL_LIMITS.min,
|
|
92
|
+
rangeMaxValue || ZOOM_LEVEL_LIMITS.max
|
|
93
|
+
]}
|
|
94
|
+
value0={zoomMin}
|
|
95
|
+
value1={zoomMax}
|
|
96
|
+
onChange={_onChange}
|
|
97
|
+
isRanged={true}
|
|
98
|
+
showTooltip
|
|
99
|
+
showInput
|
|
100
|
+
inputTheme="secondary"
|
|
101
|
+
inputSize="tiny"
|
|
102
|
+
/>
|
|
103
|
+
</SliderWrapper>
|
|
104
|
+
</div>
|
|
105
|
+
</SidePanelSection>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
LayerVisibilityByZoom.propTypes = {
|
|
111
|
+
updateLayerConfig: PropTypes.func.isRequired,
|
|
112
|
+
rangeMinValue: PropTypes.number,
|
|
113
|
+
rangeMaxValue: PropTypes.number,
|
|
114
|
+
iconComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.func])
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return LayerVisibilityByZoom;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export default LayerVisibilityByZoomFactory;
|
package/src/layers/base-layer.js
CHANGED
|
@@ -36,7 +36,8 @@ import {
|
|
|
36
36
|
SCALE_FUNC,
|
|
37
37
|
CHANNEL_SCALE_SUPPORTED_FIELDS,
|
|
38
38
|
MAX_GPU_FILTERS,
|
|
39
|
-
UNKNOWN_COLOR
|
|
39
|
+
UNKNOWN_COLOR,
|
|
40
|
+
ZOOM_LEVEL_LIMITS
|
|
40
41
|
} from 'constants/default-settings';
|
|
41
42
|
import {COLOR_RANGES} from 'constants/color-ranges';
|
|
42
43
|
import {DataVizColors} from 'constants/custom-color-ranges';
|
|
@@ -298,6 +299,10 @@ class Layer {
|
|
|
298
299
|
getDefaultLayerConfig(props = {}) {
|
|
299
300
|
return {
|
|
300
301
|
dataId: props.dataId || null,
|
|
302
|
+
visibilityByZoom: {
|
|
303
|
+
min: props.visibilityByZoom?.min || ZOOM_LEVEL_LIMITS.min,
|
|
304
|
+
max: props.visibilityByZoom?.max || ZOOM_LEVEL_LIMITS.max
|
|
305
|
+
},
|
|
301
306
|
label: props.label || DEFAULT_LAYER_LABEL,
|
|
302
307
|
color: props.color || colorMaker.next().value,
|
|
303
308
|
columns: props.columns || null,
|
|
@@ -464,7 +469,6 @@ class Layer {
|
|
|
464
469
|
shallowCopy,
|
|
465
470
|
notToCopy
|
|
466
471
|
});
|
|
467
|
-
|
|
468
472
|
this.updateLayerConfig(copied);
|
|
469
473
|
// validate visualChannel field type and scale types
|
|
470
474
|
Object.keys(this.visualChannels).forEach(channel => {
|
|
@@ -1215,7 +1219,6 @@ class Layer {
|
|
|
1215
1219
|
|
|
1216
1220
|
getDefaultDeckLayerProps({idx, gpuFilter, mapState, visible, maskPolygon}) {
|
|
1217
1221
|
const maskExtensionProps = getMaskExtensionProps(maskPolygon);
|
|
1218
|
-
|
|
1219
1222
|
return {
|
|
1220
1223
|
...maskExtensionProps,
|
|
1221
1224
|
id: this.id,
|
|
@@ -1225,6 +1228,10 @@ class Layer {
|
|
|
1225
1228
|
wrapLongitude: true,
|
|
1226
1229
|
parameters: {depthTest: Boolean(mapState.dragRotate || this.config.visConfig.enable3d)},
|
|
1227
1230
|
hidden: this.config.hidden,
|
|
1231
|
+
visibilityByZoom: {
|
|
1232
|
+
min: this.config.visibilityByZoom.min,
|
|
1233
|
+
max: this.config.visibilityByZoom.max
|
|
1234
|
+
},
|
|
1228
1235
|
// visconfig
|
|
1229
1236
|
opacity: this.config.visConfig.opacity,
|
|
1230
1237
|
highlightColor: this.config.highlightColor,
|
package/src/layers/index.d.ts
CHANGED
package/src/localization/ca.js
CHANGED
|
@@ -163,6 +163,9 @@ export default {
|
|
|
163
163
|
heightRange: 'Rang alçada',
|
|
164
164
|
heightMultiplier: "Multiplicador d'alçada"
|
|
165
165
|
},
|
|
166
|
+
layerVisibility: {
|
|
167
|
+
title: 'Visibilitat per nivell de zoom'
|
|
168
|
+
},
|
|
166
169
|
layerManager: {
|
|
167
170
|
addData: 'Afegeix Dades',
|
|
168
171
|
addLayer: 'Afegeix Capes',
|
package/src/localization/cn.js
CHANGED
package/src/localization/en.js
CHANGED
package/src/localization/es.js
CHANGED
|
@@ -164,6 +164,9 @@ export default {
|
|
|
164
164
|
heightRange: 'Rango de alturas',
|
|
165
165
|
heightMultiplier: 'Multiplicador de altura'
|
|
166
166
|
},
|
|
167
|
+
layerVisibility: {
|
|
168
|
+
title: 'Visibilidad por nivel de zoom'
|
|
169
|
+
},
|
|
167
170
|
layerManager: {
|
|
168
171
|
addData: 'Añadir datos',
|
|
169
172
|
addLayer: 'Añadir capa',
|
package/src/localization/fi.js
CHANGED
package/src/localization/ja.js
CHANGED
package/src/localization/pt.js
CHANGED
|
@@ -162,6 +162,9 @@ export default {
|
|
|
162
162
|
heightRange: 'Alcance da Altura',
|
|
163
163
|
heightMultiplier: 'Multiplicador de altura'
|
|
164
164
|
},
|
|
165
|
+
layerVisibility: {
|
|
166
|
+
title: 'Visibilidade por nível de zoom'
|
|
167
|
+
},
|
|
165
168
|
layerManager: {
|
|
166
169
|
addData: 'Adicionar Dados',
|
|
167
170
|
addLayer: 'Adicionar Camada',
|
package/src/localization/ru.js
CHANGED
|
@@ -164,6 +164,9 @@ export default {
|
|
|
164
164
|
heightRange: 'Диапазон высоты',
|
|
165
165
|
heightMultiplier: 'Множитель высоты'
|
|
166
166
|
},
|
|
167
|
+
layerVisibility: {
|
|
168
|
+
title: 'Видимость по уровню масштабирования'
|
|
169
|
+
},
|
|
167
170
|
layerManager: {
|
|
168
171
|
addData: 'Добавить данные',
|
|
169
172
|
addLayer: 'Добавить слой',
|
|
@@ -491,7 +491,8 @@ export function validateLayerWithData(
|
|
|
491
491
|
color: savedLayer.config.color,
|
|
492
492
|
isVisible: savedLayer.config.isVisible,
|
|
493
493
|
hidden: savedLayer.config.hidden,
|
|
494
|
-
highlightColor: savedLayer.config.highlightColor
|
|
494
|
+
highlightColor: savedLayer.config.highlightColor,
|
|
495
|
+
visibilityByZoom: savedLayer.config.visibilityByZoom
|
|
495
496
|
});
|
|
496
497
|
|
|
497
498
|
// find column fieldIdx
|
|
@@ -70,6 +70,7 @@ export type SavedLayer = {
|
|
|
70
70
|
isVisible: boolean;
|
|
71
71
|
visConfig: object;
|
|
72
72
|
hidden: boolean;
|
|
73
|
+
visibilityByZoom: {min: number; max: number};
|
|
73
74
|
textLabel: Merge<LayerTextLabel, {field: {name: string; type: string} | null}>;
|
|
74
75
|
};
|
|
75
76
|
visualChannels: SavedVisualChannels;
|
|
@@ -235,6 +235,7 @@ export const layerPropsV0 = {
|
|
|
235
235
|
color: new LayerConfigSchemaV0({key: 'color'}),
|
|
236
236
|
isVisible: new LayerConfigSchemaV0({key: 'isVisible'}),
|
|
237
237
|
hidden: new LayerConfigSchemaV0({key: 'hidden'}),
|
|
238
|
+
visibilityByZoom: new LayerConfigSchemaV0({key: 'visibilityByZoom'}),
|
|
238
239
|
|
|
239
240
|
// convert visConfig
|
|
240
241
|
visConfig: new LayerVisConfigSchemaV0({key: 'visConfig'}),
|
|
@@ -451,6 +452,7 @@ export const layerPropsV1 = {
|
|
|
451
452
|
version: VERSIONS.v1
|
|
452
453
|
}),
|
|
453
454
|
hidden: null,
|
|
455
|
+
visibilityByZoom: null,
|
|
454
456
|
textLabel: new TextLabelSchemaV1({
|
|
455
457
|
version: VERSIONS.v1,
|
|
456
458
|
key: 'textLabel'
|