Skip to content

Commit 98cd061

Browse files
Aaron Caldwellelasticmachine
andauthored
[7.x] Fix TMS not loaded in legacy maps (#73570) (#74307)
Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
1 parent c8ba717 commit 98cd061

File tree

6 files changed

+16
-52
lines changed

6 files changed

+16
-52
lines changed

src/plugins/maps_legacy/public/map/service_settings.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class ServiceSettings {
3030
constructor(mapConfig, tilemapsConfig) {
3131
this._mapConfig = mapConfig;
3232
this._tilemapsConfig = tilemapsConfig;
33+
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';
3334

3435
this._showZoomMessage = true;
3536
this._emsClient = new EMSClient({
@@ -53,13 +54,10 @@ export class ServiceSettings {
5354
linkify: true,
5455
});
5556

56-
// TMS attribution
57-
const attributionFromConfig = _.escape(
58-
markdownIt.render(this._tilemapsConfig.deprecated.config.options.attribution || '')
59-
);
6057
// TMS Options
61-
this.tmsOptionsFromConfig = _.assign({}, this._tilemapsConfig.deprecated.config.options, {
62-
attribution: attributionFromConfig,
58+
this.tmsOptionsFromConfig = _.assign({}, this._tilemapsConfig.options, {
59+
attribution: _.escape(markdownIt.render(this._tilemapsConfig.options.attribution || '')),
60+
url: this._tilemapsConfig.url,
6361
});
6462
}
6563

@@ -122,7 +120,7 @@ export class ServiceSettings {
122120
*/
123121
async getTMSServices() {
124122
let allServices = [];
125-
if (this._tilemapsConfig.deprecated.isOverridden) {
123+
if (this._hasTmsConfigured) {
126124
//use tilemap.* settings from yml
127125
const tmsService = _.cloneDeep(this.tmsOptionsFromConfig);
128126
tmsService.id = TMS_IN_YML_ID;
@@ -210,14 +208,12 @@ export class ServiceSettings {
210208
if (tmsServiceConfig.origin === ORIGIN.EMS) {
211209
return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
212210
} else if (tmsServiceConfig.origin === ORIGIN.KIBANA_YML) {
213-
const config = this._tilemapsConfig.deprecated.config;
214-
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
211+
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
215212
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
216213
} else {
217214
//this is an older config. need to resolve this dynamically.
218215
if (tmsServiceConfig.id === TMS_IN_YML_ID) {
219-
const config = this._tilemapsConfig.deprecated.config;
220-
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
216+
const attrs = _.pick(this._tilemapsConfig, ['url', 'minzoom', 'maxzoom', 'attribution']);
221217
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
222218
} else {
223219
//assume ems

src/plugins/maps_legacy/public/map/service_settings.test.js

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ describe('service_settings (FKA tile_map test)', function () {
4949
};
5050

5151
const defaultTilemapConfig = {
52-
deprecated: {
53-
config: {
54-
options: {},
55-
},
56-
},
52+
options: {},
5753
};
5854

5955
function makeServiceSettings(mapConfigOptions = {}, tilemapOptions = {}) {
@@ -160,13 +156,8 @@ describe('service_settings (FKA tile_map test)', function () {
160156
serviceSettings = makeServiceSettings(
161157
{},
162158
{
163-
deprecated: {
164-
isOverridden: true,
165-
config: {
166-
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
167-
options: { minZoom: 0, maxZoom: 20 },
168-
},
169-
},
159+
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
160+
options: { minZoom: 0, maxZoom: 20 },
170161
}
171162
);
172163

@@ -251,13 +242,8 @@ describe('service_settings (FKA tile_map test)', function () {
251242
includeElasticMapsService: false,
252243
},
253244
{
254-
deprecated: {
255-
isOverridden: true,
256-
config: {
257-
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
258-
options: { minZoom: 0, maxZoom: 20 },
259-
},
260-
},
245+
url: 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
246+
options: { minZoom: 0, maxZoom: 20 },
261247
}
262248
);
263249
const tilemapServices = await serviceSettings.getTMSServices();

src/plugins/region_map/public/__tests__/region_map_visualization.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,8 @@ describe('RegionMapsVisualizationTests', function () {
111111
emsLandingPageUrl: '',
112112
};
113113
const tilemapsConfig = {
114-
deprecated: {
115-
config: {
116-
options: {
117-
attribution: '123',
118-
},
119-
},
114+
options: {
115+
attribution: '123',
120116
},
121117
};
122118
const serviceSettings = new ServiceSettings(mapConfig, tilemapsConfig);

src/plugins/tile_map/config.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ import { schema, TypeOf } from '@kbn/config-schema';
2121

2222
export const configSchema = schema.object({
2323
url: schema.maybe(schema.string()),
24-
deprecated: schema.any({
25-
defaultValue: {
26-
config: {
27-
options: {
28-
attribution: '',
29-
},
30-
},
31-
},
32-
}),
3324
options: schema.object({
3425
attribution: schema.string({ defaultValue: '' }),
3526
minZoom: schema.number({ defaultValue: 0, min: 0 }),

src/plugins/tile_map/public/__tests__/coordinate_maps_visualization.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,8 @@ describe('CoordinateMapsVisualizationTest', function () {
9898
emsLandingPageUrl: '',
9999
};
100100
const tilemapsConfig = {
101-
deprecated: {
102-
config: {
103-
options: {
104-
attribution: '123',
105-
},
106-
},
101+
options: {
102+
attribution: '123',
107103
},
108104
};
109105

src/plugins/tile_map/server/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { configSchema, ConfigSchema } from '../config';
2323
export const config: PluginConfigDescriptor<ConfigSchema> = {
2424
exposeToBrowser: {
2525
url: true,
26-
deprecated: true,
2726
options: true,
2827
},
2928
schema: configSchema,

0 commit comments

Comments
 (0)