Skip to content

Commit e8e8f78

Browse files
VladLasitsaalexwizpkibanamachine
authored
[Vega] Use mapbox instead of leaflet (#88605)
* [WIP][Vega] Use mapbox instead of leaflet #78395 add MapServiceSettings class some work add tms_raster_layer add LayerParameters type clenup view.ts some cleeanup fix grammar some refactoring and add attribution control Some refactoring Add some validation for zoom settings and destroy handler Some refactoring some work fix bundle size Move getZoomSettings to the separate file update licence some work move logger to createViewConfig add throttling for updating vega layer * move EMSClient to a separate bundle * [unit testing] add tests for validation_helper.ts * [Bundle optimization] lazy loading of '@elastic/ems-client' only if user open map layer * [Map] fix cursor: crosshair -> auto * [unit testing] add tests for tms_raster_layer.test * [unit testing] add tests for vega_layer.ts * VSI related code was moved into a separate file / unit tests were added * Add functional test for vega map * [unit testing] add tests for map_service_setting.ts * Add unload in function test and delete some unneeded code from test * road_map -> road_map_desaturated * [unit testing] add more tests for map_service_settings.test.ts * Add unit tests for view.ts * Fix some remarks * Fix unit tests * remove tms_tile_layers enum * [unit testing] fix map_service_settings.test.ts * Fix unit test for view.ts * Fix some comments * Fix type check * Fix CI Co-authored-by: Alexey Antonov <[email protected]> Co-authored-by: Kibana Machine <[email protected]>
1 parent da1a4e9 commit e8e8f78

33 files changed

+1265
-249
lines changed

src/plugins/vis_type_vega/public/__snapshots__/vega_visualization.test.js.snap

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/vis_type_vega/public/plugin.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ import {
1717
setData,
1818
setInjectedVars,
1919
setUISettings,
20-
setMapsLegacyConfig,
2120
setInjectedMetadata,
21+
setMapServiceSettings,
2222
} from './services';
2323

2424
import { createVegaFn } from './vega_fn';
2525
import { createVegaTypeDefinition } from './vega_type';
26-
import { IServiceSettings } from '../../maps_legacy/public';
26+
import { IServiceSettings, MapsLegacyPluginSetup } from '../../maps_legacy/public';
2727
import { ConfigSchema } from '../config';
2828

2929
import { getVegaInspectorView } from './vega_inspector';
3030
import { getVegaVisRenderer } from './vega_vis_renderer';
31+
import { MapServiceSettings } from './vega_view/vega_map_view/map_service_settings';
3132

3233
/** @internal */
3334
export interface VegaVisualizationDependencies {
@@ -44,7 +45,7 @@ export interface VegaPluginSetupDependencies {
4445
visualizations: VisualizationsSetup;
4546
inspector: InspectorSetup;
4647
data: DataPublicPluginSetup;
47-
mapsLegacy: any;
48+
mapsLegacy: MapsLegacyPluginSetup;
4849
}
4950

5051
/** @internal */
@@ -68,8 +69,12 @@ export class VegaPlugin implements Plugin<Promise<void>, void> {
6869
enableExternalUrls: this.initializerContext.config.get().enableExternalUrls,
6970
emsTileLayerId: core.injectedMetadata.getInjectedVar('emsTileLayerId', true),
7071
});
72+
7173
setUISettings(core.uiSettings);
72-
setMapsLegacyConfig(mapsLegacy.config);
74+
75+
setMapServiceSettings(
76+
new MapServiceSettings(mapsLegacy.config, this.initializerContext.env.packageInfo.version)
77+
);
7378

7479
const visualizationDependencies: Readonly<VegaVisualizationDependencies> = {
7580
core,

src/plugins/vis_type_vega/public/services.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { CoreStart, NotificationsStart, IUiSettingsClient } from 'src/core/publi
1010

1111
import { DataPublicPluginStart } from '../../data/public';
1212
import { createGetterSetter } from '../../kibana_utils/public';
13-
import { MapsLegacyConfig } from '../../maps_legacy/config';
13+
import { MapServiceSettings } from './vega_view/vega_map_view/map_service_settings';
1414

1515
export const [getData, setData] = createGetterSetter<DataPublicPluginStart>('Data');
1616

@@ -24,13 +24,14 @@ export const [getInjectedMetadata, setInjectedMetadata] = createGetterSetter<
2424
CoreStart['injectedMetadata']
2525
>('InjectedMetadata');
2626

27+
export const [
28+
getMapServiceSettings,
29+
setMapServiceSettings,
30+
] = createGetterSetter<MapServiceSettings>('MapServiceSettings');
31+
2732
export const [getInjectedVars, setInjectedVars] = createGetterSetter<{
2833
enableExternalUrls: boolean;
2934
emsTileLayerId: unknown;
3035
}>('InjectedVars');
3136

32-
export const [getMapsLegacyConfig, setMapsLegacyConfig] = createGetterSetter<MapsLegacyConfig>(
33-
'MapsLegacyConfig'
34-
);
35-
3637
export const getEnableExternalUrls = () => getInjectedVars().enableExternalUrls;

src/plugins/vis_type_vega/public/test_utils/vega_map_test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://vega.github.io/schema/vega/v5.json",
33
"config": {
4-
"kibana": { "renderer": "svg", "type": "map", "mapStyle": false}
4+
"kibana": { "type": "map", "mapStyle": "default", "latitude": 25, "longitude": -70, "zoom": 3}
55
},
66
"width": 512,
77
"height": 512,

src/plugins/vis_type_vega/public/vega_view/vega_base_view.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ interface VegaViewParams {
1818
serviceSettings: IServiceSettings;
1919
filterManager: DataPublicPluginStart['query']['filterManager'];
2020
timefilter: DataPublicPluginStart['query']['timefilter']['timefilter'];
21-
// findIndex: (index: string) => Promise<...>;
2221
}
2322

2423
export class VegaBaseView {
2524
constructor(params: VegaViewParams);
2625
init(): Promise<void>;
2726
onError(error: any): void;
27+
onWarn(error: any): void;
28+
setView(map: any): void;
29+
setDebugValues(view: any, spec: any, vlspec: any): void;
30+
_addDestroyHandler(handler: Function): void;
31+
2832
destroy(): Promise<void>;
33+
34+
_$container: any;
35+
_parser: any;
36+
_vegaViewConfig: any;
37+
_serviceSettings: any;
2938
}

src/plugins/vis_type_vega/public/vega_view/vega_base_view.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ export class VegaBaseView {
160160

161161
createViewConfig() {
162162
const config = {
163-
// eslint-disable-next-line import/namespace
164-
logLevel: vega.Warn, // note: eslint has a false positive here
165163
renderer: this._parser.renderer,
166164
};
167165

@@ -189,6 +187,13 @@ export class VegaBaseView {
189187
};
190188
config.loader = loader;
191189

190+
const logger = vega.logger(vega.Warn);
191+
192+
logger.warn = this.onWarn.bind(this);
193+
logger.error = this.onError.bind(this);
194+
195+
config.logger = logger;
196+
192197
return config;
193198
}
194199

src/plugins/vis_type_vega/public/vega_view/vega_map_layer.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/plugins/vis_type_vega/public/vega_view/vega_map_view.js

Lines changed: 0 additions & 168 deletions
This file was deleted.

0 commit comments

Comments
 (0)