Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] create vector tile layer when using choropleth wizard #132648

Merged
merged 1 commit into from
May 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
AGG_TYPE,
COLOR_MAP_TYPE,
FIELD_ORIGIN,
LAYER_TYPE,
SCALING_TYPES,
SOURCE_TYPES,
STYLE_TYPE,
Expand All @@ -21,10 +22,11 @@ import {
CountAggDescriptor,
EMSFileSourceDescriptor,
ESSearchSourceDescriptor,
JoinDescriptor,
VectorStylePropertiesDescriptor,
} from '../../../../../common/descriptor_types';
import { VectorStyle } from '../../../styles/vector/vector_style';
import { GeoJsonVectorLayer } from '../../vector_layer';
import { GeoJsonVectorLayer, MvtVectorLayer } from '../../vector_layer';
import { EMSFileSource } from '../../../sources/ems_file_source';
// @ts-ignore
import { ESSearchSource } from '../../../sources/es_search_source';
Expand All @@ -38,14 +40,14 @@ function createChoroplethLayerDescriptor({
rightIndexPatternId,
rightIndexPatternTitle,
rightTermField,
setLabelStyle,
layerType,
}: {
sourceDescriptor: EMSFileSourceDescriptor | ESSearchSourceDescriptor;
leftField: string;
rightIndexPatternId: string;
rightIndexPatternTitle: string;
rightTermField: string;
setLabelStyle: boolean;
layerType: LAYER_TYPE.GEOJSON_VECTOR | LAYER_TYPE.MVT_VECTOR;
}) {
const metricsDescriptor: CountAggDescriptor = { type: AGG_TYPE.COUNT };
const joinId = uuid();
Expand Down Expand Up @@ -75,7 +77,8 @@ function createChoroplethLayerDescriptor({
},
},
};
if (setLabelStyle) {
// Styling label by join metric with MVT is not supported
if (layerType === LAYER_TYPE.GEOJSON_VECTOR) {
styleProperties[VECTOR_STYLES.LABEL_TEXT] = {
type: STYLE_TYPE.DYNAMIC,
options: {
Expand All @@ -88,26 +91,34 @@ function createChoroplethLayerDescriptor({
};
}

return GeoJsonVectorLayer.createDescriptor({
joins: [
{
leftField,
right: {
type: SOURCE_TYPES.ES_TERM_SOURCE,
id: joinId,
indexPatternId: rightIndexPatternId,
indexPatternTitle: rightIndexPatternTitle,
term: rightTermField,
metrics: [metricsDescriptor],
applyGlobalQuery: true,
applyGlobalTime: true,
applyForceRefresh: true,
},
const joins = [
{
leftField,
right: {
type: SOURCE_TYPES.ES_TERM_SOURCE,
id: joinId,
indexPatternId: rightIndexPatternId,
indexPatternTitle: rightIndexPatternTitle,
term: rightTermField,
metrics: [metricsDescriptor],
applyGlobalQuery: true,
applyGlobalTime: true,
applyForceRefresh: true,
},
],
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
});
} as JoinDescriptor,
];

return layerType === LAYER_TYPE.MVT_VECTOR
? MvtVectorLayer.createDescriptor({
joins,
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
})
: GeoJsonVectorLayer.createDescriptor({
joins,
sourceDescriptor,
style: VectorStyle.createDescriptor(styleProperties),
});
}

export function createEmsChoroplethLayerDescriptor({
Expand All @@ -132,7 +143,7 @@ export function createEmsChoroplethLayerDescriptor({
rightIndexPatternId,
rightIndexPatternTitle,
rightTermField,
setLabelStyle: true,
layerType: LAYER_TYPE.GEOJSON_VECTOR,
});
}

Expand Down Expand Up @@ -165,6 +176,6 @@ export function createEsChoroplethLayerDescriptor({
rightIndexPatternId,
rightIndexPatternTitle,
rightTermField,
setLabelStyle: false, // Styling label by join metric with MVT is not supported
layerType: LAYER_TYPE.MVT_VECTOR,
});
}