diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts index 52bd024d8116..81b0a71e8d94 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/__mocks__/regions_layer.mock.ts @@ -79,7 +79,7 @@ export const mockLayerList = [ maxZoom: 24, alpha: 0.75, visible: true, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', }, { joins: [ @@ -148,6 +148,6 @@ export const mockLayerList = [ maxZoom: 24, alpha: 0.75, visible: true, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', }, ]; diff --git a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.ts b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.ts index 7f81e9d10518..f573a2641b86 100644 --- a/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.ts +++ b/x-pack/plugins/apm/public/components/app/RumDashboard/VisitorBreakdownMap/useLayerList.ts @@ -155,7 +155,7 @@ export function useLayerList() { maxZoom: 24, alpha: 0.75, visible: true, - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, }; ES_TERM_SOURCE_REGION.whereQuery = getWhereQuery(serviceName!); @@ -179,7 +179,7 @@ export function useLayerList() { maxZoom: 24, alpha: 0.75, visible: true, - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, }; return [ diff --git a/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx index 507bfc36d47f..bf767c7e6520 100644 --- a/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx +++ b/x-pack/plugins/data_visualizer/public/application/common/components/stats_table/components/field_data_expanded_row/choropleth_map.tsx @@ -87,7 +87,7 @@ export const getChoroplethTopValuesLayer = ( }, isTimeAware: true, }, - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, }; }; diff --git a/x-pack/plugins/maps/common/constants.ts b/x-pack/plugins/maps/common/constants.ts index 0f2ce2c91773..43cca5f0c6a0 100644 --- a/x-pack/plugins/maps/common/constants.ts +++ b/x-pack/plugins/maps/common/constants.ts @@ -49,12 +49,12 @@ export function getEditPath(id: string | undefined) { } export enum LAYER_TYPE { - TILE = 'TILE', - VECTOR = 'VECTOR', - VECTOR_TILE = 'VECTOR_TILE', // for static display of mvt vector tiles with a mapbox stylesheet. Does not support any ad-hoc configurations. Used for consuming EMS vector tiles. + RASTER_TILE = 'RASTER_TILE', + GEOJSON_VECTOR = 'GEOJSON_VECTOR', + EMS_VECTOR_TILE = 'EMS_VECTOR_TILE', HEATMAP = 'HEATMAP', BLENDED_VECTOR = 'BLENDED_VECTOR', - TILED_VECTOR = 'TILED_VECTOR', // similar to a regular vector-layer, but it consumes the data as .mvt tilea iso GeoJson. It supports similar ad-hoc configurations like a regular vector layer (E.g. using IVectorStyle), although there is some loss of functionality e.g. does not support term joining + MVT_VECTOR = 'MVT_VECTOR', } export enum SOURCE_TYPES { diff --git a/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts b/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts index 4d687969308b..044678b918fd 100644 --- a/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts +++ b/x-pack/plugins/maps/common/descriptor_types/layer_descriptor_types.ts @@ -66,7 +66,7 @@ export type LayerDescriptor = { }; export type VectorLayerDescriptor = LayerDescriptor & { - type: LAYER_TYPE.VECTOR | LAYER_TYPE.TILED_VECTOR | LAYER_TYPE.BLENDED_VECTOR; + type: LAYER_TYPE.GEOJSON_VECTOR | LAYER_TYPE.MVT_VECTOR | LAYER_TYPE.BLENDED_VECTOR; joins?: JoinDescriptor[]; style: VectorStyleDescriptor; }; diff --git a/x-pack/plugins/maps/common/migrations/add_field_meta_options.js b/x-pack/plugins/maps/common/migrations/add_field_meta_options.js index 33a98c7dbf33..736fd30bfbcb 100644 --- a/x-pack/plugins/maps/common/migrations/add_field_meta_options.js +++ b/x-pack/plugins/maps/common/migrations/add_field_meta_options.js @@ -6,11 +6,12 @@ */ import _ from 'lodash'; -import { LAYER_TYPE, STYLE_TYPE } from '../constants'; +import { STYLE_TYPE } from '../constants'; function isVectorLayer(layerDescriptor) { const layerType = _.get(layerDescriptor, 'type'); - return layerType === LAYER_TYPE.VECTOR; + // can not use LAYER_TYPE because LAYER_TYPE.VECTOR does not exist >8.1 + return layerType === 'VECTOR'; } export function addFieldMetaOptions({ attributes }) { diff --git a/x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js b/x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js index 31300707d147..60587e56bdba 100644 --- a/x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js +++ b/x-pack/plugins/maps/common/migrations/add_field_meta_options.test.js @@ -41,7 +41,7 @@ describe('addFieldMetaOptions', () => { test('Should ignore static style properties', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { type: 'VECTOR', properties: { @@ -68,7 +68,7 @@ describe('addFieldMetaOptions', () => { test('Should add field meta options to dynamic style properties', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { type: 'VECTOR', properties: { @@ -94,7 +94,7 @@ describe('addFieldMetaOptions', () => { title: 'my map', layerListJSON: JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { type: 'VECTOR', properties: { diff --git a/x-pack/plugins/maps/common/migrations/add_type_to_termjoin.test.ts b/x-pack/plugins/maps/common/migrations/add_type_to_termjoin.test.ts index d795e63bf81d..5229380ac55f 100644 --- a/x-pack/plugins/maps/common/migrations/add_type_to_termjoin.test.ts +++ b/x-pack/plugins/maps/common/migrations/add_type_to_termjoin.test.ts @@ -6,14 +6,14 @@ */ import { addTypeToTermJoin } from './add_type_to_termjoin'; -import { LAYER_TYPE, SOURCE_TYPES } from '../constants'; +import { SOURCE_TYPES } from '../constants'; import { LayerDescriptor } from '../descriptor_types'; describe('addTypeToTermJoin', () => { test('Should handle missing type attribute', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', joins: [ { right: {}, diff --git a/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js b/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js index 2945b9efed95..4cf5407d7969 100644 --- a/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js +++ b/x-pack/plugins/maps/common/migrations/ems_raster_tile_to_ems_vector_tile.js @@ -6,7 +6,7 @@ */ import _ from 'lodash'; -import { SOURCE_TYPES, LAYER_TYPE } from '../constants'; +import { SOURCE_TYPES } from '../constants'; function isEmsTileSource(layerDescriptor) { const sourceType = _.get(layerDescriptor, 'sourceDescriptor.type'); @@ -15,7 +15,8 @@ function isEmsTileSource(layerDescriptor) { function isTileLayer(layerDescriptor) { const layerType = _.get(layerDescriptor, 'type'); - return layerType === LAYER_TYPE.TILE; + // can not use LAYER_TYPE because LAYER_TYPE.TILE does not exist >8.1 + return layerType === 'TILE'; } export function emsRasterTileToEmsVectorTile({ attributes }) { @@ -33,7 +34,8 @@ export function emsRasterTileToEmsVectorTile({ attributes }) { layerList.forEach((layer) => { if (isTileLayer(layer) && isEmsTileSource(layer)) { // Just need to switch layer type to migrate TILE layer to VECTOR_TILE layer - layer.type = LAYER_TYPE.VECTOR_TILE; + // can not use LAYER_TYPE because LAYER_TYPE.VECTOR_TILE does not exist >8.1 + layer.type = 'VECTOR_TILE'; } }); diff --git a/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts b/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts index 96d60e2f9238..3926c017a950 100644 --- a/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts +++ b/x-pack/plugins/maps/common/migrations/join_agg_key.test.ts @@ -5,7 +5,6 @@ * 2.0. */ -import { LAYER_TYPE } from '../constants'; import { migrateJoinAggKey } from './join_agg_key'; describe('migrateJoinAggKey', () => { @@ -65,7 +64,7 @@ describe('migrateJoinAggKey', () => { test('Should migrate vector styles from legacy join agg key to new join agg key', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', joins, style: { properties: { diff --git a/x-pack/plugins/maps/common/migrations/join_agg_key.ts b/x-pack/plugins/maps/common/migrations/join_agg_key.ts index 726855783be6..ae102f2ed540 100644 --- a/x-pack/plugins/maps/common/migrations/join_agg_key.ts +++ b/x-pack/plugins/maps/common/migrations/join_agg_key.ts @@ -71,7 +71,8 @@ export function migrateJoinAggKey({ layerList.forEach((layerDescriptor: LayerDescriptor) => { if ( - layerDescriptor.type === LAYER_TYPE.VECTOR || + // can not use LAYER_TYPE because LAYER_TYPE.VECTOR does not exist >8.1 + layerDescriptor.type === 'VECTOR' || layerDescriptor.type === LAYER_TYPE.BLENDED_VECTOR ) { const vectorLayerDescriptor = layerDescriptor as VectorLayerDescriptor; diff --git a/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js index 6dab8595663e..4aa0b7414843 100644 --- a/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js +++ b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.js @@ -6,11 +6,12 @@ */ import _ from 'lodash'; -import { DEFAULT_ICON, LAYER_TYPE, STYLE_TYPE, SYMBOLIZE_AS_TYPES } from '../constants'; +import { DEFAULT_ICON, STYLE_TYPE, SYMBOLIZE_AS_TYPES } from '../constants'; function isVectorLayer(layerDescriptor) { const layerType = _.get(layerDescriptor, 'type'); - return layerType === LAYER_TYPE.VECTOR; + // can not use LAYER_TYPE because LAYER_TYPE.VECTOR does not exist >8.1 + return layerType === 'VECTOR'; } export function migrateSymbolStyleDescriptor({ attributes }) { diff --git a/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js index 89f3c05e621e..9932fe1625c9 100644 --- a/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js +++ b/x-pack/plugins/maps/common/migrations/migrate_symbol_style_descriptor.test.js @@ -41,7 +41,7 @@ describe('migrateSymbolStyleDescriptor', () => { test('Should migrate "symbol" style descriptor', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { properties: { fillColor: { @@ -66,7 +66,7 @@ describe('migrateSymbolStyleDescriptor', () => { title: 'my map', layerListJSON: JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { properties: { fillColor: { @@ -90,7 +90,7 @@ describe('migrateSymbolStyleDescriptor', () => { test('Should migrate style descriptor without "symbol"', () => { const layerListJSON = JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { properties: { fillColor: { @@ -109,7 +109,7 @@ describe('migrateSymbolStyleDescriptor', () => { title: 'my map', layerListJSON: JSON.stringify([ { - type: LAYER_TYPE.VECTOR, + type: 'VECTOR', style: { properties: { fillColor: { diff --git a/x-pack/plugins/maps/common/migrations/rename_layer_types.test.ts b/x-pack/plugins/maps/common/migrations/rename_layer_types.test.ts new file mode 100644 index 000000000000..2504a2adb31a --- /dev/null +++ b/x-pack/plugins/maps/common/migrations/rename_layer_types.test.ts @@ -0,0 +1,83 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { renameLayerTypes } from './rename_layer_types'; + +describe('renameLayerTypes', () => { + test('Should handle missing layerListJSON attribute', () => { + const attributes = { + title: 'my map', + }; + expect(renameLayerTypes({ attributes })).toEqual({ + title: 'my map', + }); + }); + + test('Should rename TILED_VECTOR to MVT_VECTOR', () => { + const layerListJSON = JSON.stringify([ + { + type: 'TILED_VECTOR', + }, + ]); + const attributes = { + title: 'my map', + layerListJSON, + }; + expect(renameLayerTypes({ attributes })).toEqual({ + title: 'my map', + layerListJSON: '[{"type":"MVT_VECTOR"}]', + }); + }); + + test('Should rename VECTOR_TILE to EMS_VECTOR_TILE', () => { + const layerListJSON = JSON.stringify([ + { + type: 'VECTOR_TILE', + }, + ]); + const attributes = { + title: 'my map', + layerListJSON, + }; + expect(renameLayerTypes({ attributes })).toEqual({ + title: 'my map', + layerListJSON: '[{"type":"EMS_VECTOR_TILE"}]', + }); + }); + + test('Should rename VECTOR to GEOJSON_VECTOR', () => { + const layerListJSON = JSON.stringify([ + { + type: 'VECTOR', + }, + ]); + const attributes = { + title: 'my map', + layerListJSON, + }; + expect(renameLayerTypes({ attributes })).toEqual({ + title: 'my map', + layerListJSON: '[{"type":"GEOJSON_VECTOR"}]', + }); + }); + + test('Should rename TILE to RASTER_TILE', () => { + const layerListJSON = JSON.stringify([ + { + type: 'TILE', + }, + ]); + const attributes = { + title: 'my map', + layerListJSON, + }; + expect(renameLayerTypes({ attributes })).toEqual({ + title: 'my map', + layerListJSON: '[{"type":"RASTER_TILE"}]', + }); + }); +}); diff --git a/x-pack/plugins/maps/common/migrations/rename_layer_types.ts b/x-pack/plugins/maps/common/migrations/rename_layer_types.ts new file mode 100644 index 000000000000..6ba924ff3226 --- /dev/null +++ b/x-pack/plugins/maps/common/migrations/rename_layer_types.ts @@ -0,0 +1,49 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { LAYER_TYPE } from '../constants'; +import { LayerDescriptor } from '../descriptor_types'; +import { MapSavedObjectAttributes } from '../map_saved_object_type'; + +// LAYER_TYPE constants renamed in 8.1 to provide more distinguishable names that better refect layer. +// TILED_VECTOR replaced with MVT_VECTOR +// VECTOR_TILE replaced with EMS_VECTOR_TILE +// VECTOR replaced with GEOJSON_VECTOR +// TILE replaced with RASTER_TILE +export function renameLayerTypes({ + attributes, +}: { + attributes: MapSavedObjectAttributes; +}): MapSavedObjectAttributes { + if (!attributes || !attributes.layerListJSON) { + return attributes; + } + + let layerList: LayerDescriptor[] = []; + try { + layerList = JSON.parse(attributes.layerListJSON); + } catch (e) { + throw new Error('Unable to parse attribute layerListJSON'); + } + + layerList.forEach((layerDescriptor: LayerDescriptor) => { + if (layerDescriptor.type === 'TILED_VECTOR') { + layerDescriptor.type = LAYER_TYPE.MVT_VECTOR; + } else if (layerDescriptor.type === 'VECTOR_TILE') { + layerDescriptor.type = LAYER_TYPE.EMS_VECTOR_TILE; + } else if (layerDescriptor.type === 'VECTOR') { + layerDescriptor.type = LAYER_TYPE.GEOJSON_VECTOR; + } else if (layerDescriptor.type === 'TILE') { + layerDescriptor.type = LAYER_TYPE.RASTER_TILE; + } + }); + + return { + ...attributes, + layerListJSON: JSON.stringify(layerList), + }; +} diff --git a/x-pack/plugins/maps/public/actions/data_request_actions.ts b/x-pack/plugins/maps/public/actions/data_request_actions.ts index c1a6d05cc057..730135424a4d 100644 --- a/x-pack/plugins/maps/public/actions/data_request_actions.ts +++ b/x-pack/plugins/maps/public/actions/data_request_actions.ts @@ -287,7 +287,7 @@ function endDataLoad( const eventHandlers = getEventHandlers(getState()); if (eventHandlers && eventHandlers.onDataLoadEnd) { const resultMeta: ResultMeta = {}; - if (layer && layer.getType() === LAYER_TYPE.VECTOR) { + if (layer && layer.getType() === LAYER_TYPE.GEOJSON_VECTOR) { const featuresWithoutCentroids = features.filter((feature) => { return feature.properties ? !feature.properties[KBN_IS_CENTROID_FEATURE] : true; }); diff --git a/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.test.ts b/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.test.ts index cf3d87053800..eded70a75e4a 100644 --- a/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.test.ts @@ -53,7 +53,7 @@ describe('kibana.yml configured with map.tilemap.url', () => { type: 'KIBANA_TILEMAP', }, style: { type: 'TILE' }, - type: 'TILE', + type: 'RASTER_TILE', visible: true, }); }); @@ -89,7 +89,7 @@ describe('EMS is enabled', () => { type: 'EMS_TMS', }, style: { type: 'TILE' }, - type: 'VECTOR_TILE', + type: 'EMS_VECTOR_TILE', visible: true, }); }); diff --git a/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.ts b/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.ts index d285d3a36f66..e104261f9084 100644 --- a/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.ts +++ b/x-pack/plugins/maps/public/classes/layers/create_basemap_layer_descriptor.ts @@ -11,14 +11,14 @@ import { getKibanaTileMap } from '../../util'; import { getEMSSettings } from '../../kibana_services'; // @ts-expect-error import { KibanaTilemapSource } from '../sources/kibana_tilemap_source'; -import { TileLayer } from './tile_layer/tile_layer'; -import { VectorTileLayer } from './vector_tile_layer/vector_tile_layer'; +import { RasterTileLayer } from './raster_tile_layer/raster_tile_layer'; +import { EmsVectorTileLayer } from './ems_vector_tile_layer/ems_vector_tile_layer'; import { EMSTMSSource } from '../sources/ems_tms_source'; export function createBasemapLayerDescriptor(): LayerDescriptor | null { const tilemapSourceFromKibana = getKibanaTileMap(); if (_.get(tilemapSourceFromKibana, 'url')) { - const layerDescriptor = TileLayer.createDescriptor({ + const layerDescriptor = RasterTileLayer.createDescriptor({ sourceDescriptor: KibanaTilemapSource.createDescriptor(), }); return layerDescriptor; @@ -26,7 +26,7 @@ export function createBasemapLayerDescriptor(): LayerDescriptor | null { const isEmsEnabled = getEMSSettings()!.isEMSEnabled(); if (isEmsEnabled) { - const layerDescriptor = VectorTileLayer.createDescriptor({ + const layerDescriptor = EmsVectorTileLayer.createDescriptor({ sourceDescriptor: EMSTMSSource.createDescriptor({ isAutoSelect: true }), }); return layerDescriptor; diff --git a/x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.test.ts b/x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.test.ts new file mode 100644 index 000000000000..8b27bacff8ec --- /dev/null +++ b/x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.test.ts @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { SOURCE_TYPES } from '../../../../common/constants'; +import { DataFilters, XYZTMSSourceDescriptor } from '../../../../common/descriptor_types'; +import { ILayer } from '../layer'; +import { EmsVectorTileLayer } from './ems_vector_tile_layer'; +import { DataRequestContext } from '../../../actions'; +import { EMSTMSSource } from '../../sources/ems_tms_source'; + +describe('EmsVectorTileLayer', () => { + it('should correctly inject tileLayerId in meta', async () => { + const layer: ILayer = new EmsVectorTileLayer({ + source: { + getTileLayerId: () => { + return 'myTileLayerId'; + }, + getVectorStyleSheetAndSpriteMeta: () => { + throw new Error('network error'); + }, + } as unknown as EMSTMSSource, + layerDescriptor: { + id: 'layerid', + sourceDescriptor: { + type: SOURCE_TYPES.EMS_XYZ, + urlTemplate: 'https://example.com/{x}/{y}/{z}.png', + id: 'mockSourceId', + } as XYZTMSSourceDescriptor, + }, + }); + + let actualMeta; + let actualErrorMessage; + const mockContext = { + startLoading: (requestId: string, token: string, meta: unknown) => { + actualMeta = meta; + }, + onLoadError: (requestId: string, token: string, message: string) => { + actualErrorMessage = message; + }, + dataFilters: { foo: 'bar' } as unknown as DataFilters, + } as unknown as DataRequestContext; + + await layer.syncData(mockContext); + + expect(actualMeta).toStrictEqual({ tileLayerId: 'myTileLayerId' }); + expect(actualErrorMessage).toStrictEqual('network error'); + }); +}); diff --git a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.tsx b/x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.tsx similarity index 93% rename from x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.tsx rename to x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.tsx index f6c4e3fd057c..8f7471f255a5 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/ems_vector_tile_layer/ems_vector_tile_layer.tsx @@ -7,7 +7,7 @@ import type { Map as MbMap, Layer as MbLayer, Style as MbStyle } from '@kbn/mapbox-gl'; import _ from 'lodash'; -import { TileLayer } from '../tile_layer/tile_layer'; +import { AbstractLayer } from '../layer'; import { SOURCE_DATA_REQUEST_ID, LAYER_TYPE, LAYER_STYLE_TYPE } from '../../../../common/constants'; import { LayerDescriptor } from '../../../../common/descriptor_types'; import { DataRequest } from '../../util/data_request'; @@ -18,6 +18,7 @@ import { } from '../../../connected_components/mb_map/utils'; import { DataRequestContext } from '../../../actions'; import { EMSTMSSource } from '../../sources/ems_tms_source'; +import { TileStyle } from '../../styles/tile/tile_style'; interface SourceRequestMeta { tileLayerId: string; @@ -46,22 +47,44 @@ interface SourceRequestData { }; } -// TODO - rename to EmsVectorTileLayer -export class VectorTileLayer extends TileLayer { - static type = LAYER_TYPE.VECTOR_TILE; - +export class EmsVectorTileLayer extends AbstractLayer { static createDescriptor(options: Partial) { const tileLayerDescriptor = super.createDescriptor(options); - tileLayerDescriptor.type = VectorTileLayer.type; + tileLayerDescriptor.type = LAYER_TYPE.EMS_VECTOR_TILE; tileLayerDescriptor.alpha = _.get(options, 'alpha', 1); tileLayerDescriptor.style = { type: LAYER_STYLE_TYPE.TILE }; return tileLayerDescriptor; } + private readonly _style: TileStyle; + + constructor({ + source, + layerDescriptor, + }: { + source: EMSTMSSource; + layerDescriptor: LayerDescriptor; + }) { + super({ source, layerDescriptor }); + this._style = new TileStyle(); + } + getSource(): EMSTMSSource { return super.getSource() as EMSTMSSource; } + getStyleForEditing() { + return this._style; + } + + getStyle() { + return this._style; + } + + getCurrentStyle() { + return this._style; + } + _canSkipSync({ prevDataRequest, nextMeta, @@ -349,4 +372,12 @@ export class VectorTileLayer extends TileLayer { async getLicensedFeatures() { return this._source.getLicensedFeatures(); } + + getLayerTypeIconName() { + return 'grid'; + } + + isBasemap(order: number) { + return order === 0; + } } diff --git a/x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.test.ts b/x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.test.ts similarity index 88% rename from x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.test.ts rename to x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.test.ts index 43cc69687ffb..66c5b8da0591 100644 --- a/x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.test.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { ITileLayerArguments, TileLayer } from './tile_layer'; +import { RasterTileLayer } from './raster_tile_layer'; import { SOURCE_TYPES } from '../../../../common/constants'; import { XYZTMSSourceDescriptor } from '../../../../common/descriptor_types'; import { AbstractSource } from '../../sources/source'; @@ -34,22 +34,20 @@ class MockTileSource extends AbstractSource implements ITMSSource { } } -describe('TileLayer', () => { +describe('RasterTileLayer', () => { it('should use display-label from source', async () => { const source = new MockTileSource(sourceDescriptor); - const args: ITileLayerArguments = { + const layer: ILayer = new RasterTileLayer({ source, layerDescriptor: { id: 'layerid', sourceDescriptor }, - }; - - const layer: ILayer = new TileLayer(args); + }); expect(await source.getDisplayName()).toEqual(await layer.getDisplayName()); }); it('should override with custom display-label if present', async () => { const source = new MockTileSource(sourceDescriptor); - const layer: ILayer = new TileLayer({ + const layer: ILayer = new RasterTileLayer({ source, layerDescriptor: { id: 'layerid', sourceDescriptor, label: 'custom' }, }); diff --git a/x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.ts b/x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.ts similarity index 92% rename from x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.ts rename to x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.ts index 009b447402f9..40a7276bc10d 100644 --- a/x-pack/plugins/maps/public/classes/layers/tile_layer/tile_layer.ts +++ b/x-pack/plugins/maps/public/classes/layers/raster_tile_layer/raster_tile_layer.ts @@ -14,16 +14,10 @@ import { TileStyle } from '../../styles/tile/tile_style'; import { ITMSSource } from '../../sources/tms_source'; import { DataRequestContext } from '../../../actions'; -export interface ITileLayerArguments { - source: ITMSSource; - layerDescriptor: LayerDescriptor; -} - -// TODO - rename to RasterTileLayer -export class TileLayer extends AbstractLayer { +export class RasterTileLayer extends AbstractLayer { static createDescriptor(options: Partial) { const tileLayerDescriptor = super.createDescriptor(options); - tileLayerDescriptor.type = LAYER_TYPE.TILE; + tileLayerDescriptor.type = LAYER_TYPE.RASTER_TILE; tileLayerDescriptor.alpha = _.get(options, 'alpha', 1); tileLayerDescriptor.style = { type: LAYER_STYLE_TYPE.TILE }; return tileLayerDescriptor; @@ -31,7 +25,13 @@ export class TileLayer extends AbstractLayer { private readonly _style: TileStyle; - constructor({ source, layerDescriptor }: ITileLayerArguments) { + constructor({ + source, + layerDescriptor, + }: { + source: ITMSSource; + layerDescriptor: LayerDescriptor; + }) { super({ source, layerDescriptor }); this._style = new TileStyle(); } diff --git a/x-pack/plugins/maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.tsx b/x-pack/plugins/maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.tsx index 3152ac27189b..e7fa87435cf0 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/vector_layer/geojson_vector_layer/geojson_vector_layer.tsx @@ -51,7 +51,7 @@ export class GeoJsonVectorLayer extends AbstractVectorLayer { mapColors?: string[] ): VectorLayerDescriptor { const layerDescriptor = super.createDescriptor(options) as VectorLayerDescriptor; - layerDescriptor.type = LAYER_TYPE.VECTOR; + layerDescriptor.type = LAYER_TYPE.GEOJSON_VECTOR; if (!options.style) { const styleProperties = VectorStyle.createDefaultStyleProperties(mapColors ? mapColors : []); diff --git a/x-pack/plugins/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx b/x-pack/plugins/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx index e266c729f26f..5ac95c9a91f6 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer.tsx @@ -42,7 +42,7 @@ export class MvtVectorLayer extends AbstractVectorLayer { mapColors?: string[] ): VectorLayerDescriptor { const layerDescriptor = super.createDescriptor(descriptor, mapColors); - layerDescriptor.type = LAYER_TYPE.TILED_VECTOR; + layerDescriptor.type = LAYER_TYPE.MVT_VECTOR; if (!layerDescriptor.style) { const styleProperties = VectorStyle.createDefaultStyleProperties(mapColors ? mapColors : []); diff --git a/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx b/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx index 71a960fc1919..0384517bf983 100644 --- a/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx +++ b/x-pack/plugins/maps/public/classes/layers/vector_layer/vector_layer.tsx @@ -113,7 +113,7 @@ export class AbstractVectorLayer extends AbstractLayer implements IVectorLayer { mapColors?: string[] ): VectorLayerDescriptor { const layerDescriptor = super.createDescriptor(options) as VectorLayerDescriptor; - layerDescriptor.type = LAYER_TYPE.VECTOR; + layerDescriptor.type = LAYER_TYPE.GEOJSON_VECTOR; if (!options.style) { const styleProperties = VectorStyle.createDefaultStyleProperties(mapColors ? mapColors : []); diff --git a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.test.ts b/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.test.ts deleted file mode 100644 index d094e53c59a9..000000000000 --- a/x-pack/plugins/maps/public/classes/layers/vector_tile_layer/vector_tile_layer.test.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { ITileLayerArguments } from '../tile_layer/tile_layer'; -import { SOURCE_TYPES } from '../../../../common/constants'; -import { DataFilters, XYZTMSSourceDescriptor } from '../../../../common/descriptor_types'; -import { AbstractSource } from '../../sources/source'; -import { ITMSSource } from '../../sources/tms_source'; -import { ILayer } from '../layer'; -import { VectorTileLayer } from './vector_tile_layer'; -import { DataRequestContext } from '../../../actions'; - -const sourceDescriptor: XYZTMSSourceDescriptor = { - type: SOURCE_TYPES.EMS_XYZ, - urlTemplate: 'https://example.com/{x}/{y}/{z}.png', - id: 'mockSourceId', -}; - -class MockTileSource extends AbstractSource implements ITMSSource { - readonly _descriptor: XYZTMSSourceDescriptor; - constructor(descriptor: XYZTMSSourceDescriptor) { - super(descriptor, {}); - this._descriptor = descriptor; - } - - async getDisplayName(): Promise { - return this._descriptor.urlTemplate; - } - - async getUrlTemplate(): Promise { - return 'template/{x}/{y}/{z}.png'; - } - - getTileLayerId() { - return this._descriptor.id; - } - - getVectorStyleSheetAndSpriteMeta() { - throw new Error('network error'); - } -} - -describe('VectorTileLayer', () => { - it('should correctly inject tileLayerId in meta', async () => { - const source = new MockTileSource(sourceDescriptor); - - const args: ITileLayerArguments = { - source, - layerDescriptor: { id: 'layerid', sourceDescriptor }, - }; - - const layer: ILayer = new VectorTileLayer(args); - - let actualMeta; - let actualErrorMessage; - const mockContext = { - startLoading: (requestId: string, token: string, meta: unknown) => { - actualMeta = meta; - }, - onLoadError: (requestId: string, token: string, message: string) => { - actualErrorMessage = message; - }, - dataFilters: { foo: 'bar' } as unknown as DataFilters, - } as unknown as DataRequestContext; - - await layer.syncData(mockContext); - - expect(actualMeta).toStrictEqual({ tileLayerId: 'mockSourceId' }); - expect(actualErrorMessage).toStrictEqual('network error'); - }); -}); diff --git a/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/observability/create_layer_descriptor.test.ts b/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/observability/create_layer_descriptor.test.ts index 7c762ac3409f..9e843c98cb64 100644 --- a/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/observability/create_layer_descriptor.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/observability/create_layer_descriptor.test.ts @@ -165,7 +165,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }); }); @@ -345,7 +345,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }); }); diff --git a/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/security/create_layer_descriptors.test.ts b/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/security/create_layer_descriptors.test.ts index b5d4edc8cb43..b7e07e6f8e27 100644 --- a/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/security/create_layer_descriptors.test.ts +++ b/x-pack/plugins/maps/public/classes/layers/wizards/solution_layers/security/create_layer_descriptors.test.ts @@ -138,7 +138,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -248,7 +248,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -365,7 +365,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, ]); @@ -480,7 +480,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -590,7 +590,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -707,7 +707,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, ]); @@ -822,7 +822,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -932,7 +932,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, { @@ -1049,7 +1049,7 @@ describe('createLayerDescriptor', () => { }, type: 'VECTOR', }, - type: 'VECTOR', + type: 'GEOJSON_VECTOR', visible: true, }, ]); diff --git a/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_base_map_layer_wizard.tsx b/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_base_map_layer_wizard.tsx index 9138b199fd57..26afa65b9527 100644 --- a/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_base_map_layer_wizard.tsx +++ b/x-pack/plugins/maps/public/classes/sources/ems_tms_source/ems_base_map_layer_wizard.tsx @@ -8,10 +8,8 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { LayerWizard, RenderWizardArguments } from '../../layers'; -// @ts-ignore import { EMSTMSSource, getSourceTitle } from './ems_tms_source'; -// @ts-ignore -import { VectorTileLayer } from '../../layers/vector_tile_layer/vector_tile_layer'; +import { EmsVectorTileLayer } from '../../layers/ems_vector_tile_layer/ems_vector_tile_layer'; import { EmsTmsSourceConfig } from './tile_service_select'; import { CreateSourceEditor } from './create_source_editor'; import { getEMSSettings } from '../../../kibana_services'; @@ -45,7 +43,7 @@ export const emsBaseMapLayerWizardConfig: LayerWizard = { icon: WorldMapLayerIcon, renderWizard: ({ previewLayers }: RenderWizardArguments) => { const onSourceConfigChange = (sourceConfig: EmsTmsSourceConfig) => { - const layerDescriptor = VectorTileLayer.createDescriptor({ + const layerDescriptor = EmsVectorTileLayer.createDescriptor({ sourceDescriptor: EMSTMSSource.createDescriptor(sourceConfig), }); previewLayers([layerDescriptor]); diff --git a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.test.tsx b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.test.tsx index 32658447acf2..3ddb804cac21 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.test.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.test.tsx @@ -18,7 +18,7 @@ jest.mock('uuid/v4', () => { }); const defaultProps = { - currentLayerType: LAYER_TYPE.VECTOR, + currentLayerType: LAYER_TYPE.GEOJSON_VECTOR, indexPatternId: 'foobar', onChange: async () => {}, metrics: [], diff --git a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.tsx b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.tsx index ba10479a2bd2..fb748cdc63af 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_geo_grid_source/update_source_editor.tsx @@ -82,11 +82,13 @@ export class UpdateSourceEditor extends Component { _onResolutionChange = async (resolution: GRID_RESOLUTION, metrics: AggDescriptor[]) => { let newLayerType; if ( - this.props.currentLayerType === LAYER_TYPE.VECTOR || - this.props.currentLayerType === LAYER_TYPE.TILED_VECTOR + this.props.currentLayerType === LAYER_TYPE.GEOJSON_VECTOR || + this.props.currentLayerType === LAYER_TYPE.MVT_VECTOR ) { newLayerType = - resolution === GRID_RESOLUTION.SUPER_FINE ? LAYER_TYPE.TILED_VECTOR : LAYER_TYPE.VECTOR; + resolution === GRID_RESOLUTION.SUPER_FINE + ? LAYER_TYPE.MVT_VECTOR + : LAYER_TYPE.GEOJSON_VECTOR; } await this.props.onChange( diff --git a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/scaling_form.tsx b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/scaling_form.tsx index ddf727842780..fcf915618a0b 100644 --- a/x-pack/plugins/maps/public/classes/sources/es_search_source/util/scaling_form.tsx +++ b/x-pack/plugins/maps/public/classes/sources/es_search_source/util/scaling_form.tsx @@ -86,9 +86,9 @@ export class ScalingForm extends Component { if (optionId === SCALING_TYPES.CLUSTERS) { layerType = LAYER_TYPE.BLENDED_VECTOR; } else if (optionId === SCALING_TYPES.MVT) { - layerType = LAYER_TYPE.TILED_VECTOR; + layerType = LAYER_TYPE.MVT_VECTOR; } else { - layerType = LAYER_TYPE.VECTOR; + layerType = LAYER_TYPE.GEOJSON_VECTOR; } this.props.onChange({ propName: 'scalingType', value: optionId, newLayerType: layerType }); diff --git a/x-pack/plugins/maps/public/classes/sources/kibana_tilemap_source/kibana_base_map_layer_wizard.tsx b/x-pack/plugins/maps/public/classes/sources/kibana_tilemap_source/kibana_base_map_layer_wizard.tsx index 70f56f8f4e6d..ec69989a8313 100644 --- a/x-pack/plugins/maps/public/classes/sources/kibana_tilemap_source/kibana_base_map_layer_wizard.tsx +++ b/x-pack/plugins/maps/public/classes/sources/kibana_tilemap_source/kibana_base_map_layer_wizard.tsx @@ -12,7 +12,7 @@ import { LayerWizard, RenderWizardArguments } from '../../layers'; import { CreateSourceEditor } from './create_source_editor'; // @ts-ignore import { KibanaTilemapSource, sourceTitle } from './kibana_tilemap_source'; -import { TileLayer } from '../../layers/tile_layer/tile_layer'; +import { RasterTileLayer } from '../../layers/raster_tile_layer/raster_tile_layer'; import { getKibanaTileMap } from '../../../util'; import { LAYER_WIZARD_CATEGORY } from '../../../../common/constants'; @@ -29,7 +29,7 @@ export const kibanaBasemapLayerWizardConfig: LayerWizard = { icon: 'logoKibana', renderWizard: ({ previewLayers }: RenderWizardArguments) => { const onSourceConfigChange = () => { - const layerDescriptor = TileLayer.createDescriptor({ + const layerDescriptor = RasterTileLayer.createDescriptor({ sourceDescriptor: KibanaTilemapSource.createDescriptor(), }); previewLayers([layerDescriptor]); diff --git a/x-pack/plugins/maps/public/classes/sources/wms_source/wms_layer_wizard.tsx b/x-pack/plugins/maps/public/classes/sources/wms_source/wms_layer_wizard.tsx index adbb23b921d4..19f31d481f58 100644 --- a/x-pack/plugins/maps/public/classes/sources/wms_source/wms_layer_wizard.tsx +++ b/x-pack/plugins/maps/public/classes/sources/wms_source/wms_layer_wizard.tsx @@ -12,7 +12,7 @@ import { WMSCreateSourceEditor } from './wms_create_source_editor'; // @ts-ignore import { sourceTitle, WMSSource } from './wms_source'; import { LayerWizard, RenderWizardArguments } from '../../layers'; -import { TileLayer } from '../../layers/tile_layer/tile_layer'; +import { RasterTileLayer } from '../../layers/raster_tile_layer/raster_tile_layer'; import { LAYER_WIZARD_CATEGORY } from '../../../../common/constants'; import { WebMapServiceLayerIcon } from '../../layers/wizards/icons/web_map_service_layer_icon'; @@ -29,7 +29,7 @@ export const wmsLayerWizardConfig: LayerWizard = { return; } - const layerDescriptor = TileLayer.createDescriptor({ + const layerDescriptor = RasterTileLayer.createDescriptor({ sourceDescriptor: WMSSource.createDescriptor(sourceConfig), }); previewLayers([layerDescriptor]); diff --git a/x-pack/plugins/maps/public/classes/sources/xyz_tms_source/layer_wizard.tsx b/x-pack/plugins/maps/public/classes/sources/xyz_tms_source/layer_wizard.tsx index 95a2b104c7a1..82aab592a134 100644 --- a/x-pack/plugins/maps/public/classes/sources/xyz_tms_source/layer_wizard.tsx +++ b/x-pack/plugins/maps/public/classes/sources/xyz_tms_source/layer_wizard.tsx @@ -10,7 +10,7 @@ import React from 'react'; import { XYZTMSEditor, XYZTMSSourceConfig } from './xyz_tms_editor'; import { XYZTMSSource, sourceTitle } from './xyz_tms_source'; import { LayerWizard, RenderWizardArguments } from '../../layers'; -import { TileLayer } from '../../layers/tile_layer/tile_layer'; +import { RasterTileLayer } from '../../layers/raster_tile_layer/raster_tile_layer'; import { LAYER_WIZARD_CATEGORY } from '../../../../common/constants'; import { WorldMapLayerIcon } from '../../layers/wizards/icons/world_map_layer_icon'; @@ -32,7 +32,7 @@ export const tmsLayerWizardConfig: LayerWizard = { return; } - const layerDescriptor = TileLayer.createDescriptor({ + const layerDescriptor = RasterTileLayer.createDescriptor({ sourceDescriptor: XYZTMSSource.createDescriptor(sourceConfig), }); previewLayers([layerDescriptor]); diff --git a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/edit_layer_panel.test.tsx b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/edit_layer_panel.test.tsx index 82795b8bd931..ebe0cc6a4178 100644 --- a/x-pack/plugins/maps/public/connected_components/edit_layer_panel/edit_layer_panel.test.tsx +++ b/x-pack/plugins/maps/public/connected_components/edit_layer_panel/edit_layer_panel.test.tsx @@ -57,7 +57,7 @@ const mockLayer = { return '1'; }, getType: () => { - return LAYER_TYPE.VECTOR; + return LAYER_TYPE.GEOJSON_VECTOR; }, getDisplayName: () => { return 'layer 1'; diff --git a/x-pack/plugins/maps/public/connected_components/mb_map/utils.ts b/x-pack/plugins/maps/public/connected_components/mb_map/utils.ts index 17994bf79948..f5de99d04c01 100644 --- a/x-pack/plugins/maps/public/connected_components/mb_map/utils.ts +++ b/x-pack/plugins/maps/public/connected_components/mb_map/utils.ts @@ -11,7 +11,7 @@ import { TileMetaFeature } from '../../../common/descriptor_types'; import { RGBAImage } from './image_utils'; import { isGlDrawLayer } from './sort_layers'; import { ILayer } from '../../classes/layers/layer'; -import { EmsSpriteSheet } from '../../classes/layers/vector_tile_layer/vector_tile_layer'; +import { EmsSpriteSheet } from '../../classes/layers/ems_vector_tile_layer/ems_vector_tile_layer'; import { ES_MVT_META_LAYER_NAME } from '../../classes/layers/vector_layer/mvt_vector_layer/mvt_vector_layer'; export function removeOrphanedSourcesAndLayers( diff --git a/x-pack/plugins/maps/public/locators.test.ts b/x-pack/plugins/maps/public/locators.test.ts index bfcd34c4ae71..aabae1a26c1d 100644 --- a/x-pack/plugins/maps/public/locators.test.ts +++ b/x-pack/plugins/maps/public/locators.test.ts @@ -52,7 +52,7 @@ describe('visualize url generator', () => { { id: LAYER_ID, visible: true, - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, sourceDescriptor: { id: LAYER_ID, type: SOURCE_TYPES.ES_SEARCH, @@ -70,7 +70,7 @@ describe('visualize url generator', () => { expect(location).toMatchObject({ app: 'maps', - path: `/map#/?_g=()&_a=()&initialLayers=(id%3A'13823000-99b9-11ea-9eb6-d9e8adceb647'%2CsourceDescriptor%3A(geoField%3Atest%2Cid%3A'13823000-99b9-11ea-9eb6-d9e8adceb647'%2CindexPatternId%3A'90943e30-9a47-11e8-b64d-95841ca0b247'%2Clabel%3A'Sample%20Data'%2CscalingType%3ALIMIT%2CtooltipProperties%3A!()%2Ctype%3AES_SEARCH)%2Ctype%3AVECTOR%2Cvisible%3A!t)`, + path: `/map#/?_g=()&_a=()&initialLayers=(id%3A'13823000-99b9-11ea-9eb6-d9e8adceb647'%2CsourceDescriptor%3A(geoField%3Atest%2Cid%3A'13823000-99b9-11ea-9eb6-d9e8adceb647'%2CindexPatternId%3A'90943e30-9a47-11e8-b64d-95841ca0b247'%2Clabel%3A'Sample%20Data'%2CscalingType%3ALIMIT%2CtooltipProperties%3A!()%2Ctype%3AES_SEARCH)%2Ctype%3AGEOJSON_VECTOR%2Cvisible%3A!t)`, state: {}, }); }); diff --git a/x-pack/plugins/maps/public/selectors/map_selectors.test.ts b/x-pack/plugins/maps/public/selectors/map_selectors.test.ts index 4f336d9a8ad2..6b903214f8f9 100644 --- a/x-pack/plugins/maps/public/selectors/map_selectors.test.ts +++ b/x-pack/plugins/maps/public/selectors/map_selectors.test.ts @@ -8,7 +8,7 @@ import { LAYER_STYLE_TYPE, LAYER_TYPE, SOURCE_TYPES } from '../../common/constants'; jest.mock('../classes/layers/heatmap_layer', () => {}); -jest.mock('../classes/layers/vector_tile_layer/vector_tile_layer', () => {}); +jest.mock('../classes/layers/ems_vector_tile_layer/ems_vector_tile_layer', () => {}); jest.mock('../classes/joins/inner_join', () => {}); jest.mock('../kibana_services', () => ({ getTimeFilter: () => ({ @@ -232,7 +232,7 @@ describe('getQueryableUniqueIndexPatternIds', () => { indexPatternId: string; }) { return { - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, style: { type: LAYER_STYLE_TYPE.VECTOR, }, diff --git a/x-pack/plugins/maps/public/selectors/map_selectors.ts b/x-pack/plugins/maps/public/selectors/map_selectors.ts index f58525ea6f97..5f308387e9d8 100644 --- a/x-pack/plugins/maps/public/selectors/map_selectors.ts +++ b/x-pack/plugins/maps/public/selectors/map_selectors.ts @@ -10,9 +10,8 @@ import { FeatureCollection } from 'geojson'; import _ from 'lodash'; import { Adapters } from 'src/plugins/inspector/public'; import type { Query } from 'src/plugins/data/common'; -import { TileLayer } from '../classes/layers/tile_layer/tile_layer'; -// @ts-ignore -import { VectorTileLayer } from '../classes/layers/vector_tile_layer/vector_tile_layer'; +import { RasterTileLayer } from '../classes/layers/raster_tile_layer/raster_tile_layer'; +import { EmsVectorTileLayer } from '../classes/layers/ems_vector_tile_layer/ems_vector_tile_layer'; import { BlendedVectorLayer, IVectorLayer, @@ -59,6 +58,7 @@ import { ISource } from '../classes/sources/source'; import { ITMSSource } from '../classes/sources/tms_source'; import { IVectorSource } from '../classes/sources/vector_source'; import { ESGeoGridSource } from '../classes/sources/es_geo_grid_source'; +import { EMSTMSSource } from '../classes/sources/ems_tms_source'; import { ILayer } from '../classes/layers/layer'; import { getIsReadOnly } from './ui_selectors'; @@ -70,9 +70,9 @@ export function createLayerInstance( const source: ISource = createSourceInstance(layerDescriptor.sourceDescriptor, inspectorAdapters); switch (layerDescriptor.type) { - case LAYER_TYPE.TILE: - return new TileLayer({ layerDescriptor, source: source as ITMSSource }); - case LAYER_TYPE.VECTOR: + case LAYER_TYPE.RASTER_TILE: + return new RasterTileLayer({ layerDescriptor, source: source as ITMSSource }); + case LAYER_TYPE.GEOJSON_VECTOR: const joins: InnerJoin[] = []; const vectorLayerDescriptor = layerDescriptor as VectorLayerDescriptor; if (vectorLayerDescriptor.joins) { @@ -87,8 +87,8 @@ export function createLayerInstance( joins, chartsPaletteServiceGetColor, }); - case LAYER_TYPE.VECTOR_TILE: - return new VectorTileLayer({ layerDescriptor, source: source as ITMSSource }); + case LAYER_TYPE.EMS_VECTOR_TILE: + return new EmsVectorTileLayer({ layerDescriptor, source: source as EMSTMSSource }); case LAYER_TYPE.HEATMAP: return new HeatmapLayer({ layerDescriptor: layerDescriptor as HeatmapLayerDescriptor, @@ -100,7 +100,7 @@ export function createLayerInstance( source: source as IVectorSource, chartsPaletteServiceGetColor, }); - case LAYER_TYPE.TILED_VECTOR: + case LAYER_TYPE.MVT_VECTOR: return new MvtVectorLayer({ layerDescriptor: layerDescriptor as VectorLayerDescriptor, source: source as IVectorSource, diff --git a/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts b/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts index 1cbb3e92134b..1da2ca14bd16 100644 --- a/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts +++ b/x-pack/plugins/maps/public/trigger_actions/visualize_geo_field_action.ts @@ -61,7 +61,7 @@ const getMapsLink = async (context: VisualizeFieldContext) => { { id: uuid(), visible: true, - type: supportsClustering ? LAYER_TYPE.BLENDED_VECTOR : LAYER_TYPE.VECTOR, + type: supportsClustering ? LAYER_TYPE.BLENDED_VECTOR : LAYER_TYPE.GEOJSON_VECTOR, sourceDescriptor: { id: uuid(), type: SOURCE_TYPES.ES_SEARCH, diff --git a/x-pack/plugins/maps/server/embeddable_migrations.ts b/x-pack/plugins/maps/server/embeddable_migrations.ts index 962f5c4fb0d7..f5356e5eb29a 100644 --- a/x-pack/plugins/maps/server/embeddable_migrations.ts +++ b/x-pack/plugins/maps/server/embeddable_migrations.ts @@ -9,6 +9,7 @@ import type { SerializableRecord } from '@kbn/utility-types'; import { MapSavedObjectAttributes } from '../common/map_saved_object_type'; import { moveAttribution } from '../common/migrations/move_attribution'; import { setEmsTmsDefaultModes } from '../common/migrations/set_ems_tms_default_modes'; +import { renameLayerTypes } from '../common/migrations/rename_layer_types'; /* * Embeddables such as Maps, Lens, and Visualize can be embedded by value or by reference on a dashboard. @@ -42,4 +43,16 @@ export const embeddableMigrations = { return state; } }, + '8.1.0': (state: SerializableRecord) => { + try { + return { + ...state, + attributes: renameLayerTypes(state as { attributes: MapSavedObjectAttributes }), + } as SerializableRecord; + } catch (e) { + // Do not fail migration for invalid layerListJSON + // Maps application can display invalid layerListJSON error when saved object is viewed + return state; + } + }, }; diff --git a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.test.js b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.test.js index a415d181900d..796d641f3eff 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.test.js +++ b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.test.js @@ -202,7 +202,7 @@ describe('buildMapsSavedObjectsTelemetry', () => { max: 1, min: 1, }, - VECTOR: { + GEOJSON_VECTOR: { avg: 1.2, max: 2, min: 1, diff --git a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts index 93a9a118d23b..3b257fb812bf 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/maps_telemetry.ts @@ -160,7 +160,7 @@ async function isGeoShapeAggLayer(layer: LayerDescriptor): Promise { } if ( - layer.type !== LAYER_TYPE.VECTOR && + layer.type !== LAYER_TYPE.GEOJSON_VECTOR && layer.type !== LAYER_TYPE.BLENDED_VECTOR && layer.type !== LAYER_TYPE.HEATMAP ) { diff --git a/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json b/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json index 3adaaaf091e0..e9427a996ad1 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json +++ b/x-pack/plugins/maps/server/maps_telemetry/test_resources/sample_map_saved_objects.json @@ -6,7 +6,7 @@ "title": "Italy Map", "description": "", "mapStateJSON": "{\"zoom\":4.82,\"center\":{\"lon\":11.41545,\"lat\":42.0865},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"language\":\"lucene\",\"query\":\"\"}}", - "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"VECTOR\"}]", + "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"italy_provinces\"},\"id\":\"0oye8\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#0c1f70\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"053fe296-f5ae-4cb0-9e73-a5752cb9ba74\",\"indexPatternId\":\"d3d7af60-4c81-11e8-b3d7-01146121b73d\",\"geoField\":\"DestLocation\",\"requestType\":\"point\",\"resolution\":\"COARSE\"},\"id\":\"1gx22\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"color\":\"Greens\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"label\":\"Count\",\"name\":\"doc_count\",\"origin\":\"source\"},\"minSize\":4,\"maxSize\":32}}}},\"type\":\"GEOJSON_VECTOR\"}]", "uiStateJSON": "{}" }, "references": [ @@ -21,7 +21,7 @@ "title": "France Map", "description": "", "mapStateJSON": "{\"zoom\":3.43,\"center\":{\"lon\":-16.30411,\"lat\":42.88411},\"timeFilters\":{\"from\":\"now-15w\",\"to\":\"now\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"lucene\"}}", - "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"france_departments\"},\"id\":\"65xbw\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.25,\"visible\":true,\"joins\":[{\"leftField\":\"iso_3166_2\",\"right\":{\"id\":\"6a263f96-7a96-4f5a-a00e-c89178c1d017\"}}],\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#19c1e6\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"},{\"sourceDescriptor\":{\"id\":\"240125db-e612-4001-b853-50107e55d984\",\"type\":\"ES_SEARCH\",\"scalingType\":\"LIMIT\",\"indexPatternId\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"geoField\":\"geoip.location\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[]},\"id\":\"mdae9\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#1ce619\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"}]", + "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"france_departments\"},\"id\":\"65xbw\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.25,\"visible\":true,\"joins\":[{\"leftField\":\"iso_3166_2\",\"right\":{\"id\":\"6a263f96-7a96-4f5a-a00e-c89178c1d017\"}}],\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#19c1e6\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"},{\"sourceDescriptor\":{\"id\":\"240125db-e612-4001-b853-50107e55d984\",\"type\":\"ES_SEARCH\",\"scalingType\":\"LIMIT\",\"indexPatternId\":\"ff959d40-b880-11e8-a6d9-e546fe2bba5f\",\"geoField\":\"geoip.location\",\"limit\":2048,\"filterByMapBounds\":true,\"tooltipProperties\":[]},\"id\":\"mdae9\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#1ce619\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"}]", "uiStateJSON": "{}" }, "references": [ @@ -36,7 +36,7 @@ "title": "Canada Map", "description": "", "mapStateJSON": "{\"zoom\":2.12,\"center\":{\"lon\":-88.67592,\"lat\":34.23257},\"timeFilters\":{\"from\":\"now-15m\",\"to\":\"now\",\"mode\":\"quick\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"lucene\"}}", - "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"canada_provinces\"},\"id\":\"kt086\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#60895e\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"VECTOR\"}]", + "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"EMS_TMS\",\"id\":\"road_map\"},\"id\":\"csq5v\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.65,\"visible\":true,\"style\":{\"type\":\"TILE\",\"properties\":{}},\"type\":\"TILE\"},{\"sourceDescriptor\":{\"type\":\"EMS_FILE\",\"id\":\"canada_provinces\"},\"id\":\"kt086\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":0.75,\"visible\":true,\"style\":{\"type\":\"VECTOR\",\"properties\":{\"fillColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#60895e\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":1}},\"iconSize\":{\"type\":\"STATIC\",\"options\":{\"size\":10}}}},\"type\":\"GEOJSON_VECTOR\"}]", "uiStateJSON": "{}" }, "references": [ @@ -51,7 +51,7 @@ "title": "Single cluster layer with geo_shape field", "description": "", "mapStateJSON": "{\"zoom\":2.12,\"center\":{\"lon\":-88.67592,\"lat\":34.23257},\"timeFilters\":{\"from\":\"now-15m\",\"to\":\"now\",\"mode\":\"quick\"},\"refreshConfig\":{\"isPaused\":false,\"interval\":0},\"query\":{\"query\":\"\",\"language\":\"lucene\"}}", - "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"51afb7d0-c628-11ea-87d0-0242ac130003\",\"geoField\":\"geometry\",\"metrics\":[{\"type\":\"count\"}],\"requestType\":\"point\",\"resolution\":\"COARSE\",\"indexPatternId\":\"4a7f6010-0aed-11ea-9dd2-95afd7ad44d4\"},\"style\":{\"type\":\"VECTOR\",\"properties\":{\"icon\":{\"type\":\"STATIC\",\"options\":{\"value\":\"marker\"}},\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"color\":\"Blues\",\"colorCategory\":\"palette_0\",\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"},\"fieldMetaOptions\":{\"isEnabled\":true,\"sigma\":3},\"type\":\"ORDINAL\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":0}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"minSize\":7,\"maxSize\":32,\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"},\"fieldMetaOptions\":{\"isEnabled\":true,\"sigma\":3}}},\"iconOrientation\":{\"type\":\"STATIC\",\"options\":{\"orientation\":0}},\"labelText\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"}}},\"labelColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#000000\"}},\"labelSize\":{\"type\":\"STATIC\",\"options\":{\"size\":14}},\"labelBorderColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"symbolizeAs\":{\"options\":{\"value\":\"circle\"}},\"labelBorderSize\":{\"options\":{\"size\":\"SMALL\"}}},\"isTimeAware\":true},\"id\":\"8d384d5d-6353-468f-b8f8-8eaa487358c4\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"visible\":true,\"type\":\"VECTOR\",\"joins\":[]}]", + "layerListJSON": "[{\"sourceDescriptor\":{\"type\":\"ES_GEO_GRID\",\"id\":\"51afb7d0-c628-11ea-87d0-0242ac130003\",\"geoField\":\"geometry\",\"metrics\":[{\"type\":\"count\"}],\"requestType\":\"point\",\"resolution\":\"COARSE\",\"indexPatternId\":\"4a7f6010-0aed-11ea-9dd2-95afd7ad44d4\"},\"style\":{\"type\":\"VECTOR\",\"properties\":{\"icon\":{\"type\":\"STATIC\",\"options\":{\"value\":\"marker\"}},\"fillColor\":{\"type\":\"DYNAMIC\",\"options\":{\"color\":\"Blues\",\"colorCategory\":\"palette_0\",\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"},\"fieldMetaOptions\":{\"isEnabled\":true,\"sigma\":3},\"type\":\"ORDINAL\"}},\"lineColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFF\"}},\"lineWidth\":{\"type\":\"STATIC\",\"options\":{\"size\":0}},\"iconSize\":{\"type\":\"DYNAMIC\",\"options\":{\"minSize\":7,\"maxSize\":32,\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"},\"fieldMetaOptions\":{\"isEnabled\":true,\"sigma\":3}}},\"iconOrientation\":{\"type\":\"STATIC\",\"options\":{\"orientation\":0}},\"labelText\":{\"type\":\"DYNAMIC\",\"options\":{\"field\":{\"name\":\"doc_count\",\"origin\":\"source\"}}},\"labelColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#000000\"}},\"labelSize\":{\"type\":\"STATIC\",\"options\":{\"size\":14}},\"labelBorderColor\":{\"type\":\"STATIC\",\"options\":{\"color\":\"#FFFFFF\"}},\"symbolizeAs\":{\"options\":{\"value\":\"circle\"}},\"labelBorderSize\":{\"options\":{\"size\":\"SMALL\"}}},\"isTimeAware\":true},\"id\":\"8d384d5d-6353-468f-b8f8-8eaa487358c4\",\"label\":null,\"minZoom\":0,\"maxZoom\":24,\"alpha\":1,\"visible\":true,\"type\":\"GEOJSON_VECTOR\",\"joins\":[]}]", "uiStateJSON": "{}" }, "references": [ diff --git a/x-pack/plugins/maps/server/maps_telemetry/util.ts b/x-pack/plugins/maps/server/maps_telemetry/util.ts index 27190c9b8214..defc2cb9aa9b 100644 --- a/x-pack/plugins/maps/server/maps_telemetry/util.ts +++ b/x-pack/plugins/maps/server/maps_telemetry/util.ts @@ -265,7 +265,7 @@ export function getTermJoinsPerCluster( layerLists: LayerDescriptor[][] ): TELEMETRY_TERM_JOIN_COUNTS_PER_CLUSTER { return getCountsByCluster(layerLists, (layerDescriptor: LayerDescriptor) => { - return layerDescriptor.type === LAYER_TYPE.VECTOR && + return layerDescriptor.type === LAYER_TYPE.GEOJSON_VECTOR && (layerDescriptor as VectorLayerDescriptor)?.joins?.length ? TELEMETRY_TERM_JOIN : null; diff --git a/x-pack/plugins/maps/server/saved_objects/saved_object_migrations.js b/x-pack/plugins/maps/server/saved_objects/saved_object_migrations.js index 6d2324686042..986878e65eb8 100644 --- a/x-pack/plugins/maps/server/saved_objects/saved_object_migrations.js +++ b/x-pack/plugins/maps/server/saved_objects/saved_object_migrations.js @@ -18,6 +18,7 @@ import { setDefaultAutoFitToBounds } from '../../common/migrations/set_default_a import { addTypeToTermJoin } from '../../common/migrations/add_type_to_termjoin'; import { moveAttribution } from '../../common/migrations/move_attribution'; import { setEmsTmsDefaultModes } from '../../common/migrations/set_ems_tms_default_modes'; +import { renameLayerTypes } from '../../common/migrations/rename_layer_types'; function logMigrationWarning(context, errorMsg, doc) { context.log.warning( @@ -172,6 +173,19 @@ export const savedObjectMigrations = { try { const attributes = setEmsTmsDefaultModes(doc); + return { + ...doc, + attributes, + }; + } catch (e) { + logMigrationWarning(context, e.message, doc); + return doc; + } + }, + '8.1.0': (doc, context) => { + try { + const attributes = renameLayerTypes(doc); + return { ...doc, attributes, diff --git a/x-pack/plugins/ml/public/application/explorer/anomalies_map.tsx b/x-pack/plugins/ml/public/application/explorer/anomalies_map.tsx index 0eb6e356e139..cb3651e4a458 100644 --- a/x-pack/plugins/ml/public/application/explorer/anomalies_map.tsx +++ b/x-pack/plugins/ml/public/application/explorer/anomalies_map.tsx @@ -126,7 +126,7 @@ export const getChoroplethAnomaliesLayer = ( isTimeAware: true, }, visible: false, - type: LAYER_TYPE.VECTOR, + type: LAYER_TYPE.GEOJSON_VECTOR, }; }; diff --git a/x-pack/test/api_integration/apis/maps/migrations.js b/x-pack/test/api_integration/apis/maps/migrations.js index 19f79da94025..26de152f1473 100644 --- a/x-pack/test/api_integration/apis/maps/migrations.js +++ b/x-pack/test/api_integration/apis/maps/migrations.js @@ -44,7 +44,7 @@ export default function ({ getService }) { type: 'index-pattern', }, ]); - expect(resp.body.migrationVersion).to.eql({ map: '8.0.0' }); // migrtionVersion is derived from both "migrations" and "convertToMultiNamespaceVersion" fields when the object is registered + expect(resp.body.migrationVersion).to.eql({ map: '8.1.0' }); // migrtionVersion is derived from both "migrations" and "convertToMultiNamespaceVersion" fields when the object is registered expect(resp.body.attributes.layerListJSON.includes('indexPatternRefName')).to.be(true); }); @@ -90,7 +90,7 @@ export default function ({ getService }) { } expect(panels.length).to.be(1); expect(panels[0].type).to.be('map'); - expect(panels[0].version).to.be('8.0.0'); + expect(panels[0].version).to.be('8.1.0'); }); }); });