@carto/kepler.gl 0.0.48-alpha.custom-markers.5 → 0.0.48

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.
Files changed (36) hide show
  1. package/dist/components/common/field-selector.js +3 -7
  2. package/dist/components/common/item-selector/item-selector.js +1 -6
  3. package/dist/components/common/styled-components.js +2 -2
  4. package/dist/components/index.js +1 -10
  5. package/dist/components/kepler-gl.js +1 -2
  6. package/dist/components/side-panel/layer-panel/layer-configurator.js +8 -16
  7. package/dist/components/side-panel/layer-panel/vis-config-by-field-selector.js +3 -19
  8. package/dist/constants/default-settings.js +6 -8
  9. package/dist/layers/base-layer.js +5 -88
  10. package/dist/layers/geojson-layer/geojson-layer.js +2 -2
  11. package/dist/layers/layer-factory.js +1 -23
  12. package/dist/layers/point-layer/point-layer.js +22 -123
  13. package/dist/localization/en.js +3 -9
  14. package/dist/processors/data-processor.js +2 -4
  15. package/dist/utils/layer-utils.js +3 -5
  16. package/dist/utils/table-utils/kepler-table.js +3 -2
  17. package/package.json +4 -7
  18. package/src/components/common/field-selector.js +6 -12
  19. package/src/components/common/item-selector/item-selector.js +0 -4
  20. package/src/components/common/styled-components.js +1 -1
  21. package/src/components/index.js +0 -1
  22. package/src/components/kepler-gl.js +0 -1
  23. package/src/components/side-panel/layer-panel/layer-configurator.js +10 -27
  24. package/src/components/side-panel/layer-panel/vis-config-by-field-selector.js +1 -11
  25. package/src/constants/default-settings.js +4 -12
  26. package/src/layers/base-layer.js +2 -70
  27. package/src/layers/geojson-layer/geojson-layer.js +1 -2
  28. package/src/layers/layer-factory.js +0 -22
  29. package/src/layers/point-layer/point-layer.js +27 -132
  30. package/src/localization/en.js +2 -8
  31. package/src/processors/data-processor.js +0 -3
  32. package/src/utils/layer-utils.js +2 -4
  33. package/src/utils/table-utils/kepler-table.js +1 -1
  34. package/CHANGELOG.md +0 -711
  35. package/dist/components/side-panel/layer-panel/custom-markers-config-group.js +0 -40
  36. package/src/components/side-panel/layer-panel/custom-markers-config-group.js +0 -30
@@ -113,9 +113,7 @@ function FieldSelectorFactory(FieldListItemFactory) {
113
113
  closeOnSelect: PropTypes.bool,
114
114
  showToken: PropTypes.bool,
115
115
  suggested: PropTypes.arrayOf(PropTypes.any),
116
- CustomChickletComponent: PropTypes.func,
117
- onBlur: PropTypes.func,
118
- onFocus: PropTypes.func
116
+ CustomChickletComponent: PropTypes.func
119
117
  };
120
118
 
121
119
  static defaultProps = {
@@ -135,17 +133,15 @@ function FieldSelectorFactory(FieldListItemFactory) {
135
133
 
136
134
  fieldsSelector = props => props.fields;
137
135
  filteredFieldsSelector = props =>
138
- props.withAggregator
139
- ? props.fields
140
- : props.fields.filter(
141
- field =>
142
- !toArray(props.value).find(d => (d.name ? d.name === field.name : d === field.name))
143
- );
136
+ props.withAggregator ? props.fields : props.fields.filter(
137
+ field =>
138
+ !toArray(props.value).find(d => (d.name ? d.name === field.name : d === field.name))
139
+ );
144
140
  valueSelector = props => props.value;
145
141
  aggregatorSelector = props => props.aggregator;
146
142
  filterFieldTypesSelector = props => props.filterFieldTypes;
147
143
  showTokenSelector = props => props.showToken;
148
- withAggregatorSelector = props => props.withAggregator;
144
+ withAggregatorSelector = props => props.withAggregator
149
145
 
150
146
  selectedItemsSelector = createSelector(
151
147
  this.fieldsSelector,
@@ -219,8 +215,6 @@ function FieldSelectorFactory(FieldListItemFactory) {
219
215
  DropdownHeaderComponent={this.props.suggested ? SuggestedFieldHeader : null}
220
216
  CustomChickletComponent={this.props.CustomChickletComponent}
221
217
  withSubOptions={this.props.withAggregator}
222
- onBlur={this.props.onBlur}
223
- onFocus={this.props.onFocus}
224
218
  />
225
219
  </div>
226
220
  );
@@ -135,7 +135,6 @@ class ItemSelector extends Component {
135
135
  multiSelect: PropTypes.bool,
136
136
  inputTheme: PropTypes.string,
137
137
  onBlur: PropTypes.func,
138
- onFocus: PropTypes.func,
139
138
  placeholder: PropTypes.string,
140
139
  closeOnSelect: PropTypes.bool,
141
140
  typeaheadPlaceholder: PropTypes.string,
@@ -243,9 +242,6 @@ class ItemSelector extends Component {
243
242
  _showTypeahead = e => {
244
243
  e.stopPropagation();
245
244
  if (!this.props.disabled && !this.props.isLoading) {
246
- if (!this.state.showTypeahead && this.props.onFocus) {
247
- this.props.onFocus();
248
- }
249
245
  this.setState({
250
246
  showTypeahead: true
251
247
  });
@@ -85,7 +85,7 @@ export const SBFlexboxNoMargin = styled.div`
85
85
  export const PanelLabel = styled.label.attrs({
86
86
  className: 'side-panel-panel__label'
87
87
  })`
88
- color: ${props => (props.active ? props.theme.labelColorActive : props.theme.labelColor)};
88
+ color: ${props => props.theme.labelColor};
89
89
  display: inline-block;
90
90
  font-size: 11px;
91
91
  font-weight: 400;
@@ -73,7 +73,6 @@ export {
73
73
  export {default as LayerPanelFactory} from './side-panel/layer-panel/layer-panel';
74
74
  export {default as LayerPanelHeaderFactory} from './side-panel/layer-panel/layer-panel-header';
75
75
  export {default as LayerConfiguratorFactory} from './side-panel/layer-panel/layer-configurator';
76
- export {default as CustomMarkersConfigGroupFactory} from './side-panel/layer-panel/custom-markers-config-group';
77
76
  export {default as TextLabelPanelFactory} from './side-panel/layer-panel/text-label-panel';
78
77
  export {LayerConfigGroupLabelFactory} from './side-panel/layer-panel/layer-config-group';
79
78
  export {default as LayerVisibilityByZoomFactory} from './side-panel/layer-panel/layer-visibility-by-zoom';
@@ -130,7 +130,6 @@ export const mapFieldsSelector = props => ({
130
130
  clicked: props.visState.clicked,
131
131
  mousePos: props.visState.mousePos,
132
132
  animationConfig: props.visState.animationConfig,
133
- customMarkersStatus: props.visState.customMarkersStatus,
134
133
 
135
134
  // uiState
136
135
  activeSidePanel: props.uiState.activeSidePanel,
@@ -36,7 +36,6 @@ import SourceDataSelectorFactory from 'components/side-panel/common/source-data-
36
36
  import VisConfigSwitchFactory from './vis-config-switch';
37
37
  import VisConfigSliderFactory from './vis-config-slider';
38
38
  import LayerConfigGroupFactory, {ConfigGroupCollapsibleContent} from './layer-config-group';
39
- import CustomMarkersConfigGroupFactory from './custom-markers-config-group';
40
39
  import TextLabelPanelFactory from './text-label-panel';
41
40
 
42
41
  import {capitalizeFirstLetter} from 'utils/utils';
@@ -103,8 +102,7 @@ LayerConfiguratorFactory.deps = [
103
102
  LayerVisibilityByZoomFactory,
104
103
  LayerColorSelectorFactory,
105
104
  LayerColorRangeSelectorFactory,
106
- ArcLayerColorSelectorFactory,
107
- CustomMarkersConfigGroupFactory
105
+ ArcLayerColorSelectorFactory
108
106
  ];
109
107
 
110
108
  export default function LayerConfiguratorFactory(
@@ -120,8 +118,7 @@ export default function LayerConfiguratorFactory(
120
118
  LayerVisibilityByZoom,
121
119
  LayerColorSelector,
122
120
  LayerColorRangeSelector,
123
- ArcLayerColorSelector,
124
- CustomMarkersConfigGroup
121
+ ArcLayerColorSelector
125
122
  ) {
126
123
  class LayerConfigurator extends Component {
127
124
  static propTypes = {
@@ -202,19 +199,8 @@ export default function LayerConfiguratorFactory(
202
199
  </LayerConfigGroup>
203
200
  ) : null}
204
201
 
205
- {layer.type === LAYER_TYPES.point ? (
206
- <CustomMarkersConfigGroup
207
- layer={layer}
208
- visConfiguratorProps={visConfiguratorProps}
209
- layerChannelConfigProps={layerChannelConfigProps}
210
- />
211
- ) : null}
212
-
213
202
  {/* Radius */}
214
- <LayerConfigGroup
215
- label={layer.config.visConfig.customMarkers ? 'layer.size' : 'layer.radius'}
216
- collapsible
217
- >
203
+ <LayerConfigGroup label={'layer.radius'} collapsible>
218
204
  {!layer.config.sizeField ? (
219
205
  <VisConfigSlider
220
206
  {...layer.visConfigSettings.radius}
@@ -239,7 +225,6 @@ export default function LayerConfiguratorFactory(
239
225
  <VisConfigSwitch
240
226
  {...layer.visConfigSettings.fixedRadius}
241
227
  {...visConfiguratorProps}
242
- disabled={layer.config.visConfig.customMarkers}
243
228
  />
244
229
  ) : null}
245
230
  </ConfigGroupCollapsibleContent>
@@ -1046,6 +1031,7 @@ export function LayerColorSelectorFactory(ColorSelector) {
1046
1031
  class LayerColorSelector extends Component {
1047
1032
  render() {
1048
1033
  const {layer, onChange, selectedColor, property = 'color', setColorUI} = this.props;
1034
+
1049
1035
  return (
1050
1036
  <SidePanelSection>
1051
1037
  <PanelLabel>
@@ -1074,6 +1060,7 @@ export function ArcLayerColorSelectorFactory(ColorSelector) {
1074
1060
  class ArcLayerColorSelector extends Component {
1075
1061
  render() {
1076
1062
  const {layer, onChangeConfig, onChangeVisConfig, property = 'color', setColorUI} = this.props;
1063
+
1077
1064
  return (
1078
1065
  <SidePanelSection>
1079
1066
  <PanelLabel>
@@ -1166,17 +1153,14 @@ export function ChannelByValueSelectorFactory(VisConfigByFieldSelector) {
1166
1153
  const scaleOptions = layer.getScaleOptions(channel.key);
1167
1154
  const showScaleCustomizable =
1168
1155
  channelScaleType === CHANNEL_SCALES.color &&
1169
- scale &&
1170
1156
  layer.config[scale] &&
1171
1157
  Boolean(layer.config[field]) &&
1172
- scaleOptions?.length > 0;
1173
- const showScale = Boolean(
1158
+ scaleOptions.length > 0;
1159
+ const showScale =
1174
1160
  !showScaleCustomizable &&
1175
- scale &&
1176
- !layer.isAggregated &&
1177
- layer.config[scale] &&
1178
- scaleOptions?.length > 1
1179
- );
1161
+ !layer.isAggregated &&
1162
+ layer.config[scale] &&
1163
+ scaleOptions.length > 1;
1180
1164
  const defaultDescription = 'layerConfiguration.defaultDescription';
1181
1165
  const visRange = layer.config.visConfig[range];
1182
1166
  const aggregator = layer.config.visConfig[aggregation];
@@ -1306,5 +1290,4 @@ export const AggregationTypeSelector = ({layer, channel, onChange}) => {
1306
1290
  </SidePanelSection>
1307
1291
  );
1308
1292
  };
1309
-
1310
1293
  /* eslint-enable max-params */
@@ -62,14 +62,6 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
62
62
  this.props.updateField(val);
63
63
  };
64
64
 
65
- _onFieldSelectorFocused = () => {
66
- this.setState({fieldSelectorActive: true});
67
- };
68
-
69
- _onFieldSelectorBlur = () => {
70
- this.setState({fieldSelectorActive: false});
71
- };
72
-
73
65
  render() {
74
66
  const {
75
67
  property,
@@ -88,7 +80,7 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
88
80
  <SidePanelSection>
89
81
  <SidePanelSection>
90
82
  <PanelLabelWrapper>
91
- <PanelLabel active={this.state?.fieldSelectorActive}>
83
+ <PanelLabel>
92
84
  {(label && <FormattedMessage id={label} />) || (
93
85
  <FormattedMessage
94
86
  id="layer.propertyBasedOn"
@@ -118,8 +110,6 @@ function VisConfigByFieldSelectorFactory(InfoHelper, FieldSelector, ColorDimensi
118
110
  isLoading={this.props.isLoading}
119
111
  withAggregator={this.props.fieldsAggregated}
120
112
  aggregator={this.props.fieldsAggregated && this.props.aggregator}
121
- onFocus={this._onFieldSelectorFocused}
122
- onBlur={this._onFieldSelectorBlur}
123
113
  />
124
114
  </SidePanelSection>
125
115
  <div>
@@ -431,10 +431,8 @@ export const CHANNEL_SCALES = keyMirror({
431
431
  color: null,
432
432
  radius: null,
433
433
  size: null,
434
- customMarker: null,
435
434
  colorAggr: null,
436
- sizeAggr: null,
437
- identity: null
435
+ sizeAggr: null
438
436
  });
439
437
 
440
438
  export const AGGREGATION_TYPES = {
@@ -507,9 +505,7 @@ export const FIELD_AGGREGATORS = [
507
505
  export const linearFieldScaleFunctions = {
508
506
  [CHANNEL_SCALES.color]: [SCALE_TYPES.quantize, SCALE_TYPES.quantile, SCALE_TYPES.custom],
509
507
  [CHANNEL_SCALES.radius]: [SCALE_TYPES.sqrt],
510
- [CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log],
511
- [CHANNEL_SCALES.customMarker]: [SCALE_TYPES.ordinal],
512
- [CHANNEL_SCALES.identity]: []
508
+ [CHANNEL_SCALES.size]: [SCALE_TYPES.linear, SCALE_TYPES.sqrt, SCALE_TYPES.log]
513
509
  };
514
510
 
515
511
  export const linearFieldAggrScaleFunctions = {
@@ -537,9 +533,7 @@ export const linearFieldAggrScaleFunctions = {
537
533
  export const ordinalFieldScaleFunctions = {
538
534
  [CHANNEL_SCALES.color]: [SCALE_TYPES.ordinal],
539
535
  [CHANNEL_SCALES.radius]: [SCALE_TYPES.point],
540
- [CHANNEL_SCALES.size]: [SCALE_TYPES.point],
541
- [CHANNEL_SCALES.customMarker]: [SCALE_TYPES.ordinal],
542
- [CHANNEL_SCALES.identity]: []
536
+ [CHANNEL_SCALES.size]: [SCALE_TYPES.point]
543
537
  };
544
538
 
545
539
  export const ordinalFieldAggrScaleFunctions = {
@@ -560,9 +554,7 @@ export const ordinalFieldAggrScaleFunctions = {
560
554
  export const notSupportedScaleOpts = {
561
555
  [CHANNEL_SCALES.color]: [],
562
556
  [CHANNEL_SCALES.radius]: [],
563
- [CHANNEL_SCALES.size]: [],
564
- [CHANNEL_SCALES.customMarker]: [],
565
- [CHANNEL_SCALES.identity]: []
557
+ [CHANNEL_SCALES.size]: []
566
558
  };
567
559
 
568
560
  export const notSupportAggrOpts = {
@@ -56,7 +56,6 @@ import {getSampleData} from 'utils/table-utils/data-container-utils';
56
56
 
57
57
  import {hexToRgb, getColorGroupByName, reverseColorRange} from 'utils/color-utils';
58
58
  import {getMaskExtensionProps} from 'utils/layer-utils';
59
- import {scaleOrdinal} from 'd3-scale';
60
59
 
61
60
  /** @typedef {import('./index').Layer} LayerClass} */
62
61
 
@@ -66,17 +65,12 @@ import {scaleOrdinal} from 'd3-scale';
66
65
  */
67
66
  export const LAYER_ID_LENGTH = 6;
68
67
 
69
- // Note, this is is SVG of solid circle encoded as data-uri
70
- const FALLBACK_ICON =
71
- 'data:image/svg+xml;charset=utf-8;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCiAgPGNpcmNsZSBjeD0iNTAiIGN5PSI1MCIgcj0iNTAiLz4NCjwvc3ZnPg==';
72
-
73
68
  const MAX_SAMPLE_SIZE = 5000;
74
69
  const defaultDomain = [0, 1];
75
70
  const dataFilterExtension = new DataFilterExtension({filterSize: MAX_GPU_FILTERS});
76
71
 
77
72
  const defaultDataAccessor = dc => d => d;
78
73
  const defaultGetFieldValue = (field, d) => field.valueAccessor(d);
79
- const scaleIdentity = v => v;
80
74
 
81
75
  export const OVERLAY_TYPE = keymirror({
82
76
  deckgl: null,
@@ -814,31 +808,6 @@ class Layer {
814
808
  return this.getVisChannelScale(colorScale, colorDomain, colorRange.colors.map(hexToRgb));
815
809
  }
816
810
 
817
- getCustomMarkersScale(range) {
818
- let unknownValue = FALLBACK_ICON;
819
- if (!range) {
820
- return () => unknownValue;
821
- }
822
-
823
- const mapping = new Map();
824
-
825
- if (range.othersMarker) {
826
- unknownValue = range.othersMarker;
827
- }
828
- for (const {value, markerUrl} of range.markerMap) {
829
- if (markerUrl) {
830
- mapping.set(value, markerUrl);
831
- }
832
- }
833
-
834
- // @ts-ignore d3 scale
835
- const scale = scaleOrdinal()
836
- .domain(Array.from(mapping.keys()))
837
- .range(Array.from(mapping.values()))
838
- .unknown(unknownValue);
839
- return scale;
840
- }
841
-
842
811
  /**
843
812
  * Mapping from visual channels to deck.gl accesors
844
813
  * @param {Object} param Parameters
@@ -849,7 +818,6 @@ class Layer {
849
818
  getAttributeAccessors({dataAccessor = defaultDataAccessor, dataContainer}) {
850
819
  const attributeAccessors = {};
851
820
 
852
- // eslint-disable-next-line complexity
853
821
  Object.keys(this.visualChannels).forEach(channel => {
854
822
  const {
855
823
  field,
@@ -865,9 +833,7 @@ class Layer {
865
833
  aggregation
866
834
  } = this.visualChannels[channel];
867
835
 
868
- const shouldGetScale = Boolean(
869
- (scale || channelScaleType === CHANNEL_SCALES.identity) && this.config[field]
870
- );
836
+ const shouldGetScale = this.config[field];
871
837
 
872
838
  if (shouldGetScale) {
873
839
  const args = [this.config[scale], this.config[domain], this.config.visConfig[range]];
@@ -878,12 +844,8 @@ class Layer {
878
844
  const aggregationValue = this.config.visConfig[aggregation];
879
845
 
880
846
  const scaleFunction =
881
- channelScaleType === CHANNEL_SCALES.identity
882
- ? scaleIdentity
883
- : channelScaleType === CHANNEL_SCALES.color
847
+ channelScaleType === CHANNEL_SCALES.color
884
848
  ? this.getColorScale(...args)
885
- : channelScaleType === CHANNEL_SCALES.customMarker
886
- ? this.getCustomMarkersScale(this.config.visConfig[range])
887
849
  : this.getVisChannelScale(...args, isFixed);
888
850
 
889
851
  attributeAccessors[accessor] = d =>
@@ -1229,12 +1191,6 @@ class Layer {
1229
1191
  return fixed ? 1 : (this.config[field] ? 1 : radius);
1230
1192
  }
1231
1193
 
1232
- getMaxMarkerSize() {
1233
- const {sizeField, visConfig} = this.config;
1234
- const {radiusRange, radius} = visConfig;
1235
- return Math.ceil((sizeField ? radiusRange[1] : radius));
1236
- }
1237
-
1238
1194
  getRadiusUnit(fixedRadius) {
1239
1195
  const radiusChannel = Object.values(this.visualChannels).find(vc => vc.property === 'radius');
1240
1196
 
@@ -1344,30 +1300,6 @@ class Layer {
1344
1300
  }, []);
1345
1301
  }
1346
1302
 
1347
- /**
1348
- * Create deck.gl `IconLayer` "autoPack" mode accessor for custom markers.
1349
- *
1350
- * @param {*} customMarkersStatus Record<url, UrlStatus> provided by builder, UrlStatus `ok` means URL is ok and ready to render
1351
- * @param {*} iconUrlAccessor deck.gl accessor (or value) that resolves to URL of icon for given row
1352
- * @returns deck.gl accessor that returns UnpackedIcon ready to consume by IconLayer
1353
- */
1354
- getCustomMarkerIconAccessor(customMarkersStatus, iconUrlAccessor) {
1355
- const maxIconSize = this.getMaxMarkerSize();
1356
-
1357
- return d => {
1358
- const wantedUrl =
1359
- (typeof iconUrlAccessor === 'function') ? iconUrlAccessor(d) : iconUrlAccessor;
1360
- const url = customMarkersStatus?.[wantedUrl] === 'ok' ? wantedUrl : FALLBACK_ICON;
1361
- return {
1362
- id: `${url}@@${maxIconSize}`,
1363
- url,
1364
- width: maxIconSize,
1365
- height: maxIconSize,
1366
- mask: true
1367
- };
1368
- };
1369
- }
1370
-
1371
1303
  calculateDataAttribute(keplerTable, getPosition) {
1372
1304
  // implemented in subclasses
1373
1305
  return [];
@@ -30,8 +30,7 @@ import {LAYER_VIS_CONFIGS} from 'layers/layer-factory';
30
30
 
31
31
  const SUPPORTED_ANALYZER_TYPES = {
32
32
  [DATA_TYPES.GEOMETRY]: true,
33
- [DATA_TYPES.GEOMETRY_FROM_STRING]: true,
34
- [DATA_TYPES.PAIR_GEOMETRY_FROM_STRING]: true
33
+ [DATA_TYPES.GEOMETRY_FROM_STRING]: true
35
34
  };
36
35
 
37
36
  export const geojsonVisConfigs = {
@@ -26,7 +26,6 @@ import {DEFAULT_COLOR_RANGE} from 'constants/color-ranges';
26
26
  export const PROPERTY_GROUPS = keyMirror({
27
27
  color: null,
28
28
  stroke: null,
29
- customMarkers: null,
30
29
  radius: null,
31
30
  height: null,
32
31
  angle: null,
@@ -430,27 +429,6 @@ export const LAYER_VIS_CONFIGS = {
430
429
  step: 0.1,
431
430
  group: PROPERTY_GROUPS.cell,
432
431
  property: 'radius'
433
- },
434
- customMarkers: {
435
- type: 'boolean',
436
- defaultValue: false,
437
- label: 'layerVisConfigs.customMarkers',
438
- group: PROPERTY_GROUPS.customMarkers,
439
- property: 'customMarkers'
440
- },
441
- customMarkersUrl: {
442
- type: 'text',
443
- defaultValue: '',
444
- label: 'layerVisConfigs.addUrl',
445
- group: PROPERTY_GROUPS.customMarkers,
446
- property: 'customMarkersUrl'
447
- },
448
- customMarkersRange: {
449
- type: 'markers-range-select',
450
- defaultValue: undefined,
451
- label: 'layerVisConfigs.colorRange',
452
- group: PROPERTY_GROUPS.customMarkers,
453
- property: 'customMarkersRange'
454
432
  }
455
433
  };
456
434
 
@@ -20,13 +20,12 @@
20
20
 
21
21
  import {BrushingExtension} from '@deck.gl/extensions';
22
22
  import {ScatterplotLayer} from '@deck.gl/layers';
23
- import {IconLayer} from '@deck.gl/layers';
24
23
 
25
24
  import Layer from '../base-layer';
26
25
  import {hexToRgb} from 'utils/color-utils';
27
26
  import {findDefaultColorField} from 'utils/dataset-utils';
28
27
  import PointLayerIcon from './point-layer-icon';
29
- import {DEFAULT_LAYER_COLOR, CHANNEL_SCALES, UNKNOWN_COLOR} from 'constants/default-settings';
28
+ import {DEFAULT_LAYER_COLOR, CHANNEL_SCALES} from 'constants/default-settings';
30
29
 
31
30
  import {getTextOffsetByRadius, formatTextLabelData} from '../layer-text-label';
32
31
 
@@ -44,9 +43,6 @@ const brushingExtension = new BrushingExtension();
44
43
  export const pointVisConfigs = {
45
44
  radius: 'radius',
46
45
  fixedRadius: 'fixedRadius',
47
- customMarkers: 'customMarkers',
48
- customMarkersUrl: 'customMarkersUrl',
49
- customMarkersRange: 'customMarkersRange',
50
46
  opacity: 'opacity',
51
47
  outline: 'outline',
52
48
  thickness: 'thickness',
@@ -126,31 +122,6 @@ export default class PointLayer extends Layer {
126
122
  channelScaleType: 'radius',
127
123
  accessor: 'getRadius',
128
124
  defaultValue: 1
129
- },
130
- customMarkers: {
131
- property: 'customMarkers',
132
- key: 'customMarkers',
133
- field: 'customMarkersField',
134
- scale: 'customMarkersScale',
135
- domain: 'customMarkersDomain',
136
- range: 'customMarkersRange',
137
- fixed: 'customMarkersUrl',
138
- channelScaleType: CHANNEL_SCALES.customMarker,
139
- accessor: 'getIconUrl',
140
- supportedFieldTypes: ['string'],
141
- defaultValue: config => config.visConfig.customMarkersUrl,
142
- condition: config => config.visConfig.customMarkers
143
- },
144
- rotation: {
145
- property: 'rotation',
146
- key: 'rotation',
147
- field: 'rotationField',
148
- channelScaleType: CHANNEL_SCALES.identity,
149
- accessor: 'getAngle',
150
- supportedFieldTypes: ['float', 'integer', 'real', 'number'],
151
- defaultValue: () => 0,
152
- nullValue: 0,
153
- condition: config => config.rotationField
154
125
  }
155
126
  };
156
127
  }
@@ -210,10 +181,7 @@ export default class PointLayer extends Layer {
210
181
  // add stroke color visual channel
211
182
  strokeColorField: null,
212
183
  strokeColorDomain: [0, 1],
213
- strokeColorScale: 'quantile',
214
-
215
- customMarkersField: null,
216
- customMarkersScale: 'ordinal'
184
+ strokeColorScale: 'quantile'
217
185
  };
218
186
  }
219
187
 
@@ -269,22 +237,22 @@ export default class PointLayer extends Layer {
269
237
  this.updateMeta({bounds});
270
238
  }
271
239
 
272
- isLayerHovered(objectInfo) {
273
- return (
274
- (objectInfo?.picked && objectInfo?.layer?.props?.id === this.id) ||
275
- objectInfo?.layer?.props?.id === `${this.id}-icon`
276
- );
277
- }
278
-
279
- // eslint-disable-next-line complexity
280
240
  renderLayer(opts) {
281
- const {data, gpuFilter, objectHovered, mapState, interactionConfig, customMarkersStatus} = opts;
241
+ const {data, gpuFilter, objectHovered, mapState, interactionConfig} = opts;
282
242
 
283
243
  // if no field size is defined we need to pass fixed radius = false
284
244
  const fixedRadius = this.config.visConfig.fixedRadius && Boolean(this.config.sizeField);
285
245
  const radiusScale = this.getRadiusScale(fixedRadius);
286
246
  const radiusUnits = this.getRadiusUnit(fixedRadius);
287
247
 
248
+ const layerProps = {
249
+ stroked: this.config.visConfig.outline,
250
+ filled: this.config.visConfig.filled,
251
+ lineWidthScale: this.config.visConfig.thickness,
252
+ radiusScale,
253
+ ...(this.config.visConfig.fixedRadius ? {} : {radiusMaxPixels: 500})
254
+ };
255
+
288
256
  const updateTriggers = {
289
257
  getPosition: this.config.columns,
290
258
  getFilterValue: gpuFilter.filterValueUpdateTriggers,
@@ -310,97 +278,16 @@ export default class PointLayer extends Layer {
310
278
  };
311
279
  const hoveredObject = this.hasHoveredObject(objectHovered);
312
280
 
313
- const textLabelLayer = this.renderTextLabelLayer(
314
- {
315
- getPosition: data.getPosition,
316
- sharedProps,
317
- getPixelOffset,
318
- updateTriggers
319
- },
320
- opts
321
- );
322
- const commonLayerProps = {
323
- ...defaultLayerProps,
324
- parameters: {
325
- // circles will be flat on the map when the altitude column is not used
326
- depthTest: this.config.columns.altitude?.fieldIdx > -1
327
- }
328
- };
329
-
330
- const customMarkersField = this.config.customMarkersField;
331
- const {customMarkers, customMarkersUrl, customMarkersRange} = this.config.visConfig;
332
- const customMarkersConfigured =
333
- customMarkers && Boolean(customMarkersUrl || (customMarkersField && customMarkersRange));
334
- const customMarkersMisConfigured = customMarkers && !customMarkersConfigured;
335
-
336
- if (customMarkersConfigured) {
337
- const maxIconSize = this.getMaxMarkerSize();
338
- const getIcon = this.getCustomMarkerIconAccessor(customMarkersStatus, data.getIconUrl);
339
- const iconLayerProps = {
340
- getIcon,
341
- getPosition: data.getPosition,
342
- getSize: data.getRadius,
343
- getAngle: data.getAngle,
344
- sizeScale: radiusScale,
345
- sizeUnits: 'pixels',
346
- loadOptions: {
347
- image: {
348
- type: 'imagebitmap'
349
- },
350
- imagebitmap: {
351
- resizeWidth: maxIconSize,
352
- resizeHeight: maxIconSize,
353
- resizeQuality: 'high'
354
- }
355
- }
356
- };
357
-
358
- return [
359
- new IconLayer({
360
- ...commonLayerProps,
361
- ...iconLayerProps,
362
- id: `${defaultLayerProps.id}-icon`,
363
- data: data.data,
364
- getColor: this.config.visConfig.filled ? data.getFillColor : UNKNOWN_COLOR,
365
- getFilterValue: data.getFilterValue,
366
- updateTriggers: {
367
- getFilterValue: updateTriggers.getFilterValue,
368
- getColor: [updateTriggers.getFillColor, this.config.visConfig.filled],
369
- getIcon: [updateTriggers.getIconUrl, maxIconSize, customMarkersStatus],
370
- getSize: updateTriggers.getRadius,
371
- getAngle: updateTriggers.getAngle
372
- }
373
- }),
374
- ...(hoveredObject
375
- ? [
376
- new IconLayer({
377
- ...iconLayerProps,
378
- ...this.getDefaultHoverLayerProps(),
379
- id: `${defaultLayerProps.id}-icon-hovered`,
380
- data: [hoveredObject],
381
- getColor: this.config.highlightColor
382
- })
383
- ]
384
- : []),
385
- ...textLabelLayer
386
- ];
387
- }
388
-
389
- const scatterPlotLayerProps = {
390
- stroked: this.config.visConfig.outline,
391
- filled: this.config.visConfig.filled,
392
- lineWidthScale: this.config.visConfig.thickness,
393
- // TODO: invent better way to render something when customMarkers are not yet configured
394
- radiusScale: customMarkersMisConfigured ? radiusScale / 2 : radiusScale,
395
- ...(this.config.visConfig.fixedRadius ? {} : {radiusMaxPixels: 500})
396
- };
397
-
398
281
  return [
399
282
  new ScatterplotLayer({
283
+ ...defaultLayerProps,
400
284
  ...brushingProps,
285
+ ...layerProps,
401
286
  ...data,
402
- ...commonLayerProps,
403
- ...scatterPlotLayerProps,
287
+ parameters: {
288
+ // circles will be flat on the map when the altitude column is not used
289
+ depthTest: this.config.columns.altitude?.fieldIdx > -1
290
+ },
404
291
  radiusUnits,
405
292
  lineWidthUnits: 'pixels',
406
293
  updateTriggers,
@@ -411,7 +298,7 @@ export default class PointLayer extends Layer {
411
298
  ? [
412
299
  new ScatterplotLayer({
413
300
  ...this.getDefaultHoverLayerProps(),
414
- ...scatterPlotLayerProps,
301
+ ...layerProps,
415
302
  data: [hoveredObject],
416
303
  getLineColor: this.config.highlightColor,
417
304
  getFillColor: this.config.highlightColor,
@@ -421,7 +308,15 @@ export default class PointLayer extends Layer {
421
308
  ]
422
309
  : []),
423
310
  // text label layer
424
- ...textLabelLayer
311
+ ...this.renderTextLabelLayer(
312
+ {
313
+ getPosition: data.getPosition,
314
+ sharedProps,
315
+ getPixelOffset,
316
+ updateTriggers
317
+ },
318
+ opts
319
+ )
425
320
  ];
426
321
  }
427
322
  }