@@ -10,6 +10,7 @@ import {
1010 AGG_TYPE ,
1111 COLOR_MAP_TYPE ,
1212 FIELD_ORIGIN ,
13+ LAYER_TYPE ,
1314 SCALING_TYPES ,
1415 SOURCE_TYPES ,
1516 STYLE_TYPE ,
@@ -21,10 +22,11 @@ import {
2122 CountAggDescriptor ,
2223 EMSFileSourceDescriptor ,
2324 ESSearchSourceDescriptor ,
25+ JoinDescriptor ,
2426 VectorStylePropertiesDescriptor ,
2527} from '../../../../../common/descriptor_types' ;
2628import { VectorStyle } from '../../../styles/vector/vector_style' ;
27- import { GeoJsonVectorLayer } from '../../vector_layer' ;
29+ import { GeoJsonVectorLayer , MvtVectorLayer } from '../../vector_layer' ;
2830import { EMSFileSource } from '../../../sources/ems_file_source' ;
2931// @ts -ignore
3032import { ESSearchSource } from '../../../sources/es_search_source' ;
@@ -38,14 +40,14 @@ function createChoroplethLayerDescriptor({
3840 rightIndexPatternId,
3941 rightIndexPatternTitle,
4042 rightTermField,
41- setLabelStyle ,
43+ layerType ,
4244} : {
4345 sourceDescriptor : EMSFileSourceDescriptor | ESSearchSourceDescriptor ;
4446 leftField : string ;
4547 rightIndexPatternId : string ;
4648 rightIndexPatternTitle : string ;
4749 rightTermField : string ;
48- setLabelStyle : boolean ;
50+ layerType : LAYER_TYPE . GEOJSON_VECTOR | LAYER_TYPE . MVT_VECTOR ;
4951} ) {
5052 const metricsDescriptor : CountAggDescriptor = { type : AGG_TYPE . COUNT } ;
5153 const joinId = uuid ( ) ;
@@ -75,7 +77,8 @@ function createChoroplethLayerDescriptor({
7577 } ,
7678 } ,
7779 } ;
78- if ( setLabelStyle ) {
80+ // Styling label by join metric with MVT is not supported
81+ if ( layerType === LAYER_TYPE . GEOJSON_VECTOR ) {
7982 styleProperties [ VECTOR_STYLES . LABEL_TEXT ] = {
8083 type : STYLE_TYPE . DYNAMIC ,
8184 options : {
@@ -88,26 +91,34 @@ function createChoroplethLayerDescriptor({
8891 } ;
8992 }
9093
91- return GeoJsonVectorLayer . createDescriptor ( {
92- joins : [
93- {
94- leftField,
95- right : {
96- type : SOURCE_TYPES . ES_TERM_SOURCE ,
97- id : joinId ,
98- indexPatternId : rightIndexPatternId ,
99- indexPatternTitle : rightIndexPatternTitle ,
100- term : rightTermField ,
101- metrics : [ metricsDescriptor ] ,
102- applyGlobalQuery : true ,
103- applyGlobalTime : true ,
104- applyForceRefresh : true ,
105- } ,
94+ const joins = [
95+ {
96+ leftField,
97+ right : {
98+ type : SOURCE_TYPES . ES_TERM_SOURCE ,
99+ id : joinId ,
100+ indexPatternId : rightIndexPatternId ,
101+ indexPatternTitle : rightIndexPatternTitle ,
102+ term : rightTermField ,
103+ metrics : [ metricsDescriptor ] ,
104+ applyGlobalQuery : true ,
105+ applyGlobalTime : true ,
106+ applyForceRefresh : true ,
106107 } ,
107- ] ,
108- sourceDescriptor,
109- style : VectorStyle . createDescriptor ( styleProperties ) ,
110- } ) ;
108+ } as JoinDescriptor ,
109+ ] ;
110+
111+ return layerType === LAYER_TYPE . MVT_VECTOR
112+ ? MvtVectorLayer . createDescriptor ( {
113+ joins,
114+ sourceDescriptor,
115+ style : VectorStyle . createDescriptor ( styleProperties ) ,
116+ } )
117+ : GeoJsonVectorLayer . createDescriptor ( {
118+ joins,
119+ sourceDescriptor,
120+ style : VectorStyle . createDescriptor ( styleProperties ) ,
121+ } ) ;
111122}
112123
113124export function createEmsChoroplethLayerDescriptor ( {
@@ -132,7 +143,7 @@ export function createEmsChoroplethLayerDescriptor({
132143 rightIndexPatternId,
133144 rightIndexPatternTitle,
134145 rightTermField,
135- setLabelStyle : true ,
146+ layerType : LAYER_TYPE . GEOJSON_VECTOR ,
136147 } ) ;
137148}
138149
@@ -165,6 +176,6 @@ export function createEsChoroplethLayerDescriptor({
165176 rightIndexPatternId,
166177 rightIndexPatternTitle,
167178 rightTermField,
168- setLabelStyle : false , // Styling label by join metric with MVT is not supported
179+ layerType : LAYER_TYPE . MVT_VECTOR ,
169180 } ) ;
170181}
0 commit comments