Skip to content

Commit

Permalink
[Maps] better style defaults (#52420) (#52567)
Browse files Browse the repository at this point in the history
* [Maps] better style defaults

* rename consts
  • Loading branch information
nreese authored Dec 9, 2019
1 parent e7e9d01 commit c5a1b71
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand All @@ -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: {
Expand All @@ -253,8 +266,6 @@ export class ESGeoGridSource extends AbstractESAggSource {
name: COUNT_PROP_NAME,
origin: SOURCE_DATA_ID_ORIGIN
},
minSize: 4,
maxSize: 32,
}
}
});
Expand All @@ -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
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@ export class ESPewPewSource extends AbstractESAggSource {
name: COUNT_PROP_NAME,
origin: SOURCE_DATA_ID_ORIGIN
},
minSize: 4,
maxSize: 32,
}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ValidatedDualRange
min={DEFAULT_MIN_SIZE}
max={DEFAULT_MAX_SIZE}
min={MIN_SIZE}
max={MAX_SIZE}
step={1}
value={[minSize, maxSize]}
showInput="inputWithPopover"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
export const SYMBOLIZE_AS_CIRCLE = 'circle';
export const SYMBOLIZE_AS_ICON = 'icon';

export const DEFAULT_ICON_SIZE = 10;
export const DEFAULT_ICON_SIZE = 6;
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {

const DEFAULT_ICON = 'airfield';

export const DEFAULT_MIN_SIZE = 1;
export const DEFAULT_MAX_SIZE = 64;
export const MIN_SIZE = 1;
export const MAX_SIZE = 64;
export const DEFAULT_SIGMA = 3;

export const VECTOR_STYLES = {
Expand Down Expand Up @@ -112,8 +112,8 @@ export function getDefaultDynamicProperties() {
[VECTOR_STYLES.LINE_WIDTH]: {
type: VectorStyle.STYLE_TYPE.DYNAMIC,
options: {
minSize: DEFAULT_MIN_SIZE,
maxSize: DEFAULT_MAX_SIZE,
minSize: 1,
maxSize: 10,
field: undefined,
fieldMetaOptions: {
isEnabled: true,
Expand All @@ -124,8 +124,8 @@ export function getDefaultDynamicProperties() {
[VECTOR_STYLES.ICON_SIZE]: {
type: VectorStyle.STYLE_TYPE.DYNAMIC,
options: {
minSize: DEFAULT_MIN_SIZE,
maxSize: DEFAULT_MAX_SIZE,
minSize: 4,
maxSize: 32,
field: undefined,
fieldMetaOptions: {
isEnabled: true,
Expand Down

0 comments on commit c5a1b71

Please sign in to comment.