From aeb46cc9b63ff532bffad024c8a1c73d0a350cde Mon Sep 17 00:00:00 2001 From: Nathan Reese Date: Mon, 9 Dec 2019 14:38:46 -0700 Subject: [PATCH] [Maps] better style defaults (#52420) * [Maps] better style defaults * rename consts --- .../es_geo_grid_source/es_geo_grid_source.js | 35 ++++++++++++------- .../es_pew_pew_source/es_pew_pew_source.js | 2 -- .../components/size/size_range_selector.js | 10 +++--- .../layers/styles/vector/vector_constants.js | 2 +- .../styles/vector/vector_style_defaults.js | 12 +++---- 5 files changed, 35 insertions(+), 26 deletions(-) diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.js index f4cb43ad90146b..de1b47ea28a910 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_geo_grid_source/es_geo_grid_source.js @@ -25,6 +25,7 @@ import { i18n } from '@kbn/i18n'; import { getDataSourceLabel } from '../../../../common/i18n_getters'; import { AbstractESAggSource } from '../es_agg_source'; import { DynamicStyleProperty } from '../../styles/vector/properties/dynamic_style_property'; +import { StaticStyleProperty } from '../../styles/vector/properties/static_style_property'; const MAX_GEOTILE_LEVEL = 29; @@ -216,14 +217,14 @@ export class ESGeoGridSource extends AbstractESAggSource { ]; } - _createDefaultLayerDescriptor(options) { - if (this._descriptor.requestType === RENDER_AS.HEATMAP) { - return HeatmapLayer.createDescriptor({ - sourceDescriptor: this._descriptor, - ...options - }); - } + _createHeatmapLayerDescriptor(options) { + return HeatmapLayer.createDescriptor({ + sourceDescriptor: this._descriptor, + ...options + }); + } + _createVectorLayerDescriptor(options) { const descriptor = VectorLayer.createDescriptor({ sourceDescriptor: this._descriptor, ...options @@ -244,6 +245,18 @@ export class ESGeoGridSource extends AbstractESAggSource { color: 'Blues' } }, + [VECTOR_STYLES.LINE_COLOR]: { + type: StaticStyleProperty.type, + options: { + color: '#FFF' + } + }, + [VECTOR_STYLES.LINE_WIDTH]: { + type: StaticStyleProperty.type, + options: { + size: 0 + } + }, [VECTOR_STYLES.ICON_SIZE]: { type: DynamicStyleProperty.type, options: { @@ -253,8 +266,6 @@ export class ESGeoGridSource extends AbstractESAggSource { name: COUNT_PROP_NAME, origin: SOURCE_DATA_ID_ORIGIN }, - minSize: 4, - maxSize: 32, } } }); @@ -264,15 +275,15 @@ export class ESGeoGridSource extends AbstractESAggSource { createDefaultLayer(options) { if (this._descriptor.requestType === RENDER_AS.HEATMAP) { return new HeatmapLayer({ - layerDescriptor: this._createDefaultLayerDescriptor(options), + layerDescriptor: this._createHeatmapLayerDescriptor(options), source: this }); } - const layerDescriptor = this._createDefaultLayerDescriptor(options); + const layerDescriptor = this._createVectorLayerDescriptor(options); const style = new VectorStyle(layerDescriptor.style, this); return new VectorLayer({ - layerDescriptor: layerDescriptor, + layerDescriptor, source: this, style }); diff --git a/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/es_pew_pew_source.js b/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/es_pew_pew_source.js index 4eb0a952defba4..c897ee2a5b2d06 100644 --- a/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/es_pew_pew_source.js +++ b/x-pack/legacy/plugins/maps/public/layers/sources/es_pew_pew_source/es_pew_pew_source.js @@ -146,8 +146,6 @@ export class ESPewPewSource extends AbstractESAggSource { name: COUNT_PROP_NAME, origin: SOURCE_DATA_ID_ORIGIN }, - minSize: 4, - maxSize: 32, } } }); diff --git a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/size/size_range_selector.js b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/size/size_range_selector.js index 4279fbbe0fbb35..1d5815a84920cb 100644 --- a/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/size/size_range_selector.js +++ b/x-pack/legacy/plugins/maps/public/layers/styles/vector/components/size/size_range_selector.js @@ -7,21 +7,21 @@ import React from 'react'; import PropTypes from 'prop-types'; import { ValidatedDualRange } from 'ui/validated_range'; -import { DEFAULT_MIN_SIZE, DEFAULT_MAX_SIZE } from '../../vector_style_defaults'; +import { MIN_SIZE, MAX_SIZE } from '../../vector_style_defaults'; import { i18n } from '@kbn/i18n'; export function SizeRangeSelector({ minSize, maxSize, onChange, ...rest }) { const onSizeChange = ([min, max]) => { onChange({ - minSize: Math.max(DEFAULT_MIN_SIZE, parseInt(min, 10)), - maxSize: Math.min(DEFAULT_MAX_SIZE, parseInt(max, 10)), + minSize: Math.max(MIN_SIZE, parseInt(min, 10)), + maxSize: Math.min(MAX_SIZE, parseInt(max, 10)), }); }; return (