Migrate Coordinate Maps to NP (#64668)
|
@ -43,7 +43,7 @@
|
|||
"src/plugins/telemetry",
|
||||
"src/plugins/telemetry_management_section"
|
||||
],
|
||||
"tileMap": "src/legacy/core_plugins/tile_map",
|
||||
"tileMap": "src/plugins/tile_map",
|
||||
"timelion": ["src/legacy/core_plugins/timelion", "src/plugins/vis_type_timelion"],
|
||||
"uiActions": "src/plugins/ui_actions",
|
||||
"visDefaultEditor": "src/plugins/vis_default_editor",
|
||||
|
|
|
@ -21,6 +21,9 @@ import Bluebird from 'bluebird';
|
|||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import $ from 'jquery';
|
||||
|
||||
import 'leaflet/dist/leaflet.js';
|
||||
import 'leaflet-vega';
|
||||
// Will be replaced with new path when tests are moved
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createVegaVisualization } from '../../../../../../plugins/vis_type_vega/public/vega_visualization';
|
||||
|
@ -100,6 +103,39 @@ describe('VegaVisualizations', () => {
|
|||
setSavedObjects(npStart.core.savedObjects);
|
||||
setNotifications(npStart.core.notifications);
|
||||
|
||||
const mockMapConfig = {
|
||||
includeElasticMapsService: true,
|
||||
proxyElasticMapsServiceInMaps: false,
|
||||
tilemap: {
|
||||
deprecated: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
options: {
|
||||
attribution: '',
|
||||
minZoom: 0,
|
||||
maxZoom: 10,
|
||||
},
|
||||
},
|
||||
regionmap: {
|
||||
includeElasticMapsService: true,
|
||||
layers: [],
|
||||
},
|
||||
manifestServiceUrl: '',
|
||||
emsFileApiUrl: 'https://vector.maps.elastic.co',
|
||||
emsTileApiUrl: 'https://tiles.maps.elastic.co',
|
||||
emsLandingPageUrl: 'https://maps.elastic.co/v7.7',
|
||||
emsFontLibraryUrl: 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf',
|
||||
emsTileLayerId: {
|
||||
bright: 'road_map',
|
||||
desaturated: 'road_map_desaturated',
|
||||
dark: 'dark_map',
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(
|
||||
ngMock.inject(() => {
|
||||
|
@ -127,7 +163,7 @@ describe('VegaVisualizations', () => {
|
|||
return 'not found';
|
||||
}
|
||||
});
|
||||
const serviceSettings = new ServiceSettings();
|
||||
const serviceSettings = new ServiceSettings(mockMapConfig, mockMapConfig.tilemap);
|
||||
vegaVisualizationDependencies = {
|
||||
serviceSettings,
|
||||
core: {
|
||||
|
|
|
@ -45,7 +45,6 @@ import 'ui/autoload/all';
|
|||
import './management';
|
||||
import './dev_tools';
|
||||
import { showAppRedirectNotification } from '../../../../plugins/kibana_legacy/public';
|
||||
import 'leaflet';
|
||||
import { localApplicationService } from './local_application_service';
|
||||
|
||||
npSetup.plugins.kibanaLegacy.registerLegacyAppAlias('doc', 'discover', { keepPrefix: true });
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import _ from 'lodash';
|
||||
|
||||
import ChoroplethLayer from '../choropleth_layer';
|
||||
import { ImageComparator } from 'test_utils/image_comparator';
|
||||
import worldJson from './world.json';
|
||||
|
@ -103,31 +104,29 @@ describe('RegionMapsVisualizationTests', function() {
|
|||
let getManifestStub;
|
||||
beforeEach(
|
||||
ngMock.inject(() => {
|
||||
const mapConfig = {
|
||||
emsFileApiUrl: '',
|
||||
emsTileApiUrl: '',
|
||||
emsLandingPageUrl: '',
|
||||
};
|
||||
const tilemapsConfig = {
|
||||
deprecated: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '123',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
setInjectedVarFunc(injectedVar => {
|
||||
switch (injectedVar) {
|
||||
case 'mapConfig':
|
||||
return {
|
||||
emsFileApiUrl: '',
|
||||
emsTileApiUrl: '',
|
||||
emsLandingPageUrl: '',
|
||||
};
|
||||
case 'tilemapsConfig':
|
||||
return {
|
||||
deprecated: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '123',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
case 'version':
|
||||
return '123';
|
||||
default:
|
||||
return 'not found';
|
||||
}
|
||||
});
|
||||
const serviceSettings = new ServiceSettings();
|
||||
const serviceSettings = new ServiceSettings(mapConfig, tilemapsConfig);
|
||||
const regionmapsConfig = {
|
||||
includeElasticMapsService: true,
|
||||
layers: [],
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
import $ from 'jquery';
|
||||
import L from 'leaflet';
|
||||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
@ -86,6 +85,7 @@ export default class ChoroplethLayer extends KibanaMapLayer {
|
|||
this._layerName = name;
|
||||
this._layerConfig = layerConfig;
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
this._leafletLayer = L.geoJson(null, {
|
||||
onEachFeature: (feature, layer) => {
|
||||
layer.on('click', () => {
|
||||
|
@ -96,6 +96,7 @@ export default class ChoroplethLayer extends KibanaMapLayer {
|
|||
mouseover: () => {
|
||||
const tooltipContents = this._tooltipFormatter(feature);
|
||||
if (!location) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const leafletGeojson = L.geoJson(feature);
|
||||
location = leafletGeojson.getBounds().getCenter();
|
||||
}
|
||||
|
@ -428,6 +429,7 @@ CORS configuration of the server permits requests from the Kibana application on
|
|||
|
||||
const { min, max } = getMinMax(this._metrics);
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const boundsOfAllFeatures = new L.LatLngBounds();
|
||||
return {
|
||||
leafletStyleFunction: geojsonFeature => {
|
||||
|
@ -435,6 +437,7 @@ CORS configuration of the server permits requests from the Kibana application on
|
|||
if (!match) {
|
||||
return emptyStyle();
|
||||
}
|
||||
// eslint-disable-next-line no-undef
|
||||
const boundsOfFeature = L.geoJson(geojsonFeature).getBounds();
|
||||
boundsOfAllFeatures.extend(boundsOfFeature);
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { Legacy } from 'kibana';
|
||||
|
||||
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types';
|
||||
|
||||
const tileMapPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
|
||||
new Plugin({
|
||||
id: 'tile_map',
|
||||
require: ['kibana', 'elasticsearch'],
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
uiExports: {
|
||||
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
|
||||
hacks: [resolve(__dirname, 'public/legacy')],
|
||||
injectDefaultVars: server => {
|
||||
const serverConfig = server.config();
|
||||
const mapConfig: Record<string, any> = serverConfig.get('map');
|
||||
|
||||
return {
|
||||
emsTileLayerId: mapConfig.emsTileLayerId,
|
||||
};
|
||||
},
|
||||
},
|
||||
config(Joi: any) {
|
||||
return Joi.object({
|
||||
enabled: Joi.boolean().default(true),
|
||||
}).default();
|
||||
},
|
||||
} as Legacy.PluginSpecOptions);
|
||||
|
||||
// eslint-disable-next-line import/no-default-export
|
||||
export default tileMapPluginInitializer;
|
67
src/plugins/maps_legacy/config.ts
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
import { configSchema as tilemapSchema } from '../tile_map/config';
|
||||
|
||||
// TODO: Pull this portion from region_map
|
||||
export const regionmapSchema = schema.object({
|
||||
includeElasticMapsService: schema.boolean({ defaultValue: true }),
|
||||
layers: schema.arrayOf(
|
||||
schema.object({
|
||||
url: schema.string(),
|
||||
format: schema.object({
|
||||
type: schema.string({ defaultValue: 'geojson' }),
|
||||
}),
|
||||
meta: schema.object({
|
||||
feature_collection_path: schema.string({ defaultValue: 'data' }),
|
||||
}),
|
||||
attribution: schema.string(),
|
||||
name: schema.string(),
|
||||
fields: schema.arrayOf(
|
||||
schema.object({
|
||||
name: schema.string(),
|
||||
description: schema.string(),
|
||||
})
|
||||
),
|
||||
}),
|
||||
{ defaultValue: [] }
|
||||
),
|
||||
});
|
||||
|
||||
export const configSchema = schema.object({
|
||||
includeElasticMapsService: schema.boolean({ defaultValue: true }),
|
||||
proxyElasticMapsServiceInMaps: schema.boolean({ defaultValue: false }),
|
||||
tilemap: tilemapSchema,
|
||||
regionmap: regionmapSchema,
|
||||
manifestServiceUrl: schema.string({ defaultValue: '' }),
|
||||
emsFileApiUrl: schema.string({ defaultValue: 'https://vector.maps.elastic.co' }),
|
||||
emsTileApiUrl: schema.string({ defaultValue: 'https://tiles.maps.elastic.co' }),
|
||||
emsLandingPageUrl: schema.string({ defaultValue: 'https://maps.elastic.co/v7.7' }),
|
||||
emsFontLibraryUrl: schema.string({
|
||||
defaultValue: 'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf',
|
||||
}),
|
||||
emsTileLayerId: schema.object({
|
||||
bright: schema.string({ defaultValue: 'road_map' }),
|
||||
desaturated: schema.string({ defaultValue: 'road_map_desaturated' }),
|
||||
dark: schema.string({ defaultValue: 'dark_map' }),
|
||||
}),
|
||||
});
|
||||
|
||||
export type ConfigSchema = TypeOf<typeof configSchema>;
|
|
@ -2,5 +2,7 @@
|
|||
"id": "mapsLegacy",
|
||||
"version": "8.0.0",
|
||||
"kibanaVersion": "kibana",
|
||||
"ui": true
|
||||
"configPath": ["map"],
|
||||
"ui": true,
|
||||
"server": true
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { KibanaMap } from '../../map/kibana_map';
|
||||
import { KibanaMapLayer } from '../../map/kibana_map_layer';
|
||||
import L from 'leaflet';
|
||||
|
||||
describe('kibana_map tests', function() {
|
||||
let domNode;
|
||||
|
@ -218,6 +217,7 @@ describe('kibana_map tests', function() {
|
|||
function makeMockLayer(attribution) {
|
||||
const layer = new KibanaMapLayer();
|
||||
layer._attribution = attribution;
|
||||
// eslint-disable-next-line no-undef
|
||||
layer._leafletLayer = L.geoJson(null);
|
||||
return layer;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,16 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { CoreSetup } from 'kibana/public';
|
||||
// @ts-ignore
|
||||
import { CoreSetup, PluginInitializerContext } from 'kibana/public';
|
||||
// @ts-ignore
|
||||
import { L } from './leaflet';
|
||||
// @ts-ignore
|
||||
import { KibanaMap } from './map/kibana_map';
|
||||
import { bindSetupCoreAndPlugins, MapsLegacyPlugin } from './plugin';
|
||||
// @ts-ignore
|
||||
import * as colorUtil from './map/color_util';
|
||||
// @ts-ignore
|
||||
import { KibanaMap } from './map/kibana_map';
|
||||
// @ts-ignore
|
||||
import { KibanaMapLayer } from './map/kibana_map_layer';
|
||||
// @ts-ignore
|
||||
import { convertToGeoJson } from './map/convert_to_geojson';
|
||||
|
@ -41,8 +44,15 @@ import {
|
|||
// @ts-ignore
|
||||
import { mapTooltipProvider } from './tooltip_provider';
|
||||
|
||||
export function plugin() {
|
||||
return new MapsLegacyPlugin();
|
||||
export interface MapsLegacyConfigType {
|
||||
emsTileLayerId: string;
|
||||
includeElasticMapsService: boolean;
|
||||
proxyElasticMapsServiceInMaps: boolean;
|
||||
tilemap: any;
|
||||
}
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
||||
return new MapsLegacyPlugin(initializerContext);
|
||||
}
|
||||
|
||||
/** @public */
|
||||
|
@ -59,6 +69,7 @@ export {
|
|||
FileLayer,
|
||||
TmsLayer,
|
||||
mapTooltipProvider,
|
||||
L,
|
||||
};
|
||||
|
||||
// Due to a leaflet/leaflet-draw bug, it's not possible to consume leaflet maps w/ draw control
|
||||
|
|
|
@ -17,15 +17,20 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
require('../node_modules/leaflet/dist/leaflet.css');
|
||||
window.L = module.exports = require('../node_modules/leaflet/dist/leaflet');
|
||||
window.L.Browser.touch = false;
|
||||
window.L.Browser.pointer = false;
|
||||
export let L;
|
||||
|
||||
require('../node_modules/leaflet.heat/dist/leaflet-heat.js');
|
||||
if (!window.hasOwnProperty('L')) {
|
||||
require('leaflet/dist/leaflet.css');
|
||||
window.L = require('leaflet/dist/leaflet.js');
|
||||
window.L.Browser.touch = false;
|
||||
window.L.Browser.pointer = false;
|
||||
|
||||
require('../node_modules/leaflet-draw/dist/leaflet.draw.css');
|
||||
require('../node_modules/leaflet-draw/dist/leaflet.draw.js');
|
||||
|
||||
require('../node_modules/leaflet-responsive-popup/leaflet.responsive.popup.css');
|
||||
require('../node_modules/leaflet-responsive-popup/leaflet.responsive.popup.js');
|
||||
require('leaflet-vega');
|
||||
require('leaflet.heat/dist/leaflet-heat.js');
|
||||
require('leaflet-draw/dist/leaflet.draw.css');
|
||||
require('leaflet-draw/dist/leaflet.draw.js');
|
||||
require('leaflet-responsive-popup/leaflet.responsive.popup.css');
|
||||
require('leaflet-responsive-popup/leaflet.responsive.popup.js');
|
||||
} else {
|
||||
L = window.L;
|
||||
}
|
|
@ -19,15 +19,16 @@
|
|||
|
||||
import { EventEmitter } from 'events';
|
||||
import { createZoomWarningMsg } from './map_messages';
|
||||
import L from 'leaflet';
|
||||
import $ from 'jquery';
|
||||
import _ from 'lodash';
|
||||
import { zoomToPrecision } from './zoom_to_precision';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { ORIGIN } from '../common/constants/origin';
|
||||
import { getToasts } from '../kibana_services';
|
||||
import { L } from '../leaflet';
|
||||
|
||||
function makeFitControl(fitContainer, kibanaMap) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const FitControl = L.Control.extend({
|
||||
options: {
|
||||
position: 'topleft',
|
||||
|
@ -63,6 +64,7 @@ function makeFitControl(fitContainer, kibanaMap) {
|
|||
}
|
||||
|
||||
function makeLegendControl(container, kibanaMap, position) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const LegendControl = L.Control.extend({
|
||||
options: {
|
||||
position: 'topright',
|
||||
|
@ -123,11 +125,13 @@ export class KibanaMap extends EventEmitter {
|
|||
maxZoom: options.maxZoom,
|
||||
center: options.center ? options.center : [0, 0],
|
||||
zoom: options.zoom ? options.zoom : 2,
|
||||
// eslint-disable-next-line no-undef
|
||||
renderer: L.canvas(),
|
||||
zoomAnimation: false, // Desaturate map tiles causes animation rendering artifacts
|
||||
zoomControl: options.zoomControl === undefined ? true : options.zoomControl,
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
this._leafletMap = L.map(containerNode, leafletOptions);
|
||||
this._leafletMap.attributionControl.setPrefix('');
|
||||
|
||||
|
@ -228,10 +232,11 @@ export class KibanaMap extends EventEmitter {
|
|||
}
|
||||
|
||||
if (!this._popup) {
|
||||
this._popup = L.responsivePopup({ autoPan: false });
|
||||
// eslint-disable-next-line no-undef
|
||||
this._popup = new L.ResponsivePopup({ autoPan: false });
|
||||
this._popup.setLatLng(event.position);
|
||||
this._popup.setContent(event.content);
|
||||
this._popup.openOn(this._leafletMap);
|
||||
this._leafletMap.openPopup(this._popup);
|
||||
} else {
|
||||
if (!this._popup.getLatLng().equals(event.position)) {
|
||||
this._popup.setLatLng(event.position);
|
||||
|
@ -335,6 +340,7 @@ export class KibanaMap extends EventEmitter {
|
|||
}
|
||||
|
||||
setCenter(latitude, longitude) {
|
||||
// eslint-disable-next-line no-undef
|
||||
const latLong = L.latLng(latitude, longitude);
|
||||
if (latLong.equals && !latLong.equals(this._leafletMap.getCenter())) {
|
||||
this._leafletMap.setView(latLong);
|
||||
|
@ -461,6 +467,7 @@ export class KibanaMap extends EventEmitter {
|
|||
circlemarker: false,
|
||||
},
|
||||
};
|
||||
// eslint-disable-next-line no-undef
|
||||
this._leafletDrawControl = new L.Control.Draw(drawOptions);
|
||||
this._leafletMap.addControl(this._leafletDrawControl);
|
||||
}
|
||||
|
@ -470,6 +477,7 @@ export class KibanaMap extends EventEmitter {
|
|||
return;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-undef
|
||||
const fitContainer = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-control-fit');
|
||||
this._leafletFitControl = makeFitControl(fitContainer, this);
|
||||
this._leafletMap.addControl(this._leafletFitControl);
|
||||
|
@ -621,6 +629,7 @@ export class KibanaMap extends EventEmitter {
|
|||
}
|
||||
|
||||
_getTMSBaseLayer(options) {
|
||||
// eslint-disable-next-line no-undef
|
||||
return L.tileLayer(options.url, {
|
||||
minZoom: options.minZoom,
|
||||
maxZoom: options.maxZoom,
|
||||
|
@ -640,7 +649,8 @@ export class KibanaMap extends EventEmitter {
|
|||
};
|
||||
|
||||
return typeof options.url === 'string' && options.url.length
|
||||
? L.tileLayer.wms(options.url, wmsOptions)
|
||||
? // eslint-disable-next-line no-undef
|
||||
L.tileLayer.wms(options.url, wmsOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,10 +27,10 @@ import { ORIGIN } from '../common/constants/origin';
|
|||
const TMS_IN_YML_ID = 'TMS in config/kibana.yml';
|
||||
|
||||
export class ServiceSettings {
|
||||
constructor() {
|
||||
constructor(mapConfig, tilemapsConfig) {
|
||||
const getInjectedVar = getInjectedVarFunc();
|
||||
this.mapConfig = getInjectedVar('mapConfig');
|
||||
this.tilemapsConfig = getInjectedVar('tilemapsConfig');
|
||||
this._mapConfig = mapConfig;
|
||||
this._tilemapsConfig = tilemapsConfig;
|
||||
const kbnVersion = getInjectedVar('version');
|
||||
|
||||
this._showZoomMessage = true;
|
||||
|
@ -38,9 +38,9 @@ export class ServiceSettings {
|
|||
language: i18n.getLocale(),
|
||||
appVersion: kbnVersion,
|
||||
appName: 'kibana',
|
||||
fileApiUrl: this.mapConfig.emsFileApiUrl,
|
||||
tileApiUrl: this.mapConfig.emsTileApiUrl,
|
||||
landingPageUrl: this.mapConfig.emsLandingPageUrl,
|
||||
fileApiUrl: this._mapConfig.emsFileApiUrl,
|
||||
tileApiUrl: this._mapConfig.emsTileApiUrl,
|
||||
landingPageUrl: this._mapConfig.emsLandingPageUrl,
|
||||
// Wrap to avoid errors passing window fetch
|
||||
fetchFunction: function(...args) {
|
||||
return fetch(...args);
|
||||
|
@ -57,10 +57,10 @@ export class ServiceSettings {
|
|||
|
||||
// TMS attribution
|
||||
const attributionFromConfig = _.escape(
|
||||
markdownIt.render(this.tilemapsConfig.deprecated.config.options.attribution || '')
|
||||
markdownIt.render(this._tilemapsConfig.deprecated.config.options.attribution || '')
|
||||
);
|
||||
// TMS Options
|
||||
this.tmsOptionsFromConfig = _.assign({}, this.tilemapsConfig.deprecated.config.options, {
|
||||
this.tmsOptionsFromConfig = _.assign({}, this._tilemapsConfig.deprecated.config.options, {
|
||||
attribution: attributionFromConfig,
|
||||
});
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ export class ServiceSettings {
|
|||
}
|
||||
|
||||
async getFileLayers() {
|
||||
if (!this.mapConfig.includeElasticMapsService) {
|
||||
if (!this._mapConfig.includeElasticMapsService) {
|
||||
return [];
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ export class ServiceSettings {
|
|||
*/
|
||||
async getTMSServices() {
|
||||
let allServices = [];
|
||||
if (this.tilemapsConfig.deprecated.isOverridden) {
|
||||
if (this._tilemapsConfig.deprecated.isOverridden) {
|
||||
//use tilemap.* settings from yml
|
||||
const tmsService = _.cloneDeep(this.tmsOptionsFromConfig);
|
||||
tmsService.id = TMS_IN_YML_ID;
|
||||
|
@ -129,11 +129,11 @@ export class ServiceSettings {
|
|||
allServices.push(tmsService);
|
||||
}
|
||||
|
||||
if (this.mapConfig.includeElasticMapsService) {
|
||||
if (this._mapConfig.includeElasticMapsService) {
|
||||
const servicesFromManifest = await this._emsClient.getTMSServices();
|
||||
const strippedServiceFromManifest = await Promise.all(
|
||||
servicesFromManifest
|
||||
.filter(tmsService => tmsService.getId() === this.mapConfig.emsTileLayerId.bright)
|
||||
.filter(tmsService => tmsService.getId() === this._mapConfig.emsTileLayerId.bright)
|
||||
.map(async tmsService => {
|
||||
//shim for compatibility
|
||||
return {
|
||||
|
@ -173,7 +173,7 @@ export class ServiceSettings {
|
|||
|
||||
async _getAttributesForEMSTMSLayer(isDesaturated, isDarkMode) {
|
||||
const tmsServices = await this._emsClient.getTMSServices();
|
||||
const emsTileLayerId = this.mapConfig.emsTileLayerId;
|
||||
const emsTileLayerId = this._mapConfig.emsTileLayerId;
|
||||
let serviceId;
|
||||
if (isDarkMode) {
|
||||
serviceId = emsTileLayerId.dark;
|
||||
|
@ -200,13 +200,13 @@ export class ServiceSettings {
|
|||
if (tmsServiceConfig.origin === ORIGIN.EMS) {
|
||||
return this._getAttributesForEMSTMSLayer(isDesaturated, isDarkMode);
|
||||
} else if (tmsServiceConfig.origin === ORIGIN.KIBANA_YML) {
|
||||
const config = this.tilemapsConfig.deprecated.config;
|
||||
const config = this._tilemapsConfig.deprecated.config;
|
||||
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
|
||||
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
|
||||
} else {
|
||||
//this is an older config. need to resolve this dynamically.
|
||||
if (tmsServiceConfig.id === TMS_IN_YML_ID) {
|
||||
const config = this.tilemapsConfig.deprecated.config;
|
||||
const config = this._tilemapsConfig.deprecated.config;
|
||||
const attrs = _.pick(config, ['url', 'minzoom', 'maxzoom', 'attribution']);
|
||||
return { ...attrs, ...{ origin: ORIGIN.KIBANA_YML } };
|
||||
} else {
|
||||
|
|
|
@ -18,14 +18,15 @@
|
|||
*/
|
||||
|
||||
// @ts-ignore
|
||||
import { CoreSetup, CoreStart, Plugin } from 'kibana/public';
|
||||
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'kibana/public';
|
||||
// @ts-ignore
|
||||
import { setToasts, setUiSettings, setInjectedVarFunc } from './kibana_services';
|
||||
// @ts-ignore
|
||||
import { ServiceSettings } from './map/service_settings';
|
||||
// @ts-ignore
|
||||
import { getPrecision, getZoomPrecision } from './map/precision';
|
||||
import { MapsLegacyPluginSetup, MapsLegacyPluginStart } from './index';
|
||||
import { MapsLegacyConfigType, MapsLegacyPluginSetup, MapsLegacyPluginStart } from './index';
|
||||
import { ConfigSchema } from '../config';
|
||||
|
||||
/**
|
||||
* These are the interfaces with your public contracts. You should export these
|
||||
|
@ -45,13 +46,22 @@ export interface MapsLegacySetupDependencies {}
|
|||
export interface MapsLegacyStartDependencies {}
|
||||
|
||||
export class MapsLegacyPlugin implements Plugin<MapsLegacyPluginSetup, MapsLegacyPluginStart> {
|
||||
readonly _initializerContext: PluginInitializerContext<ConfigSchema>;
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
|
||||
this._initializerContext = initializerContext;
|
||||
}
|
||||
|
||||
public setup(core: CoreSetup, plugins: MapsLegacySetupDependencies) {
|
||||
bindSetupCoreAndPlugins(core);
|
||||
|
||||
const config = this._initializerContext.config.get<MapsLegacyConfigType>();
|
||||
|
||||
return {
|
||||
serviceSettings: new ServiceSettings(),
|
||||
serviceSettings: new ServiceSettings(config, config.tilemap),
|
||||
getZoomPrecision,
|
||||
getPrecision,
|
||||
config,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
49
src/plugins/maps_legacy/server/index.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { configSchema, ConfigSchema } from '../config';
|
||||
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
exposeToBrowser: {
|
||||
includeElasticMapsService: true,
|
||||
proxyElasticMapsServiceInMaps: true,
|
||||
tilemap: true,
|
||||
regionmap: true,
|
||||
manifestServiceUrl: true,
|
||||
emsFileApiUrl: true,
|
||||
emsTileApiUrl: true,
|
||||
emsLandingPageUrl: true,
|
||||
emsFontLibraryUrl: true,
|
||||
emsTileLayerId: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
};
|
||||
|
||||
export const plugin = (initializerContext: PluginInitializerContext) => ({
|
||||
setup() {
|
||||
// @ts-ignore
|
||||
const config$ = initializerContext.config.create();
|
||||
return {
|
||||
config: config$,
|
||||
};
|
||||
},
|
||||
start() {},
|
||||
});
|
47
src/plugins/tile_map/config.ts
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { schema, TypeOf } from '@kbn/config-schema';
|
||||
|
||||
export const configSchema = schema.object({
|
||||
url: schema.maybe(schema.string()),
|
||||
deprecated: schema.any({
|
||||
defaultValue: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
options: schema.object({
|
||||
attribution: schema.string({ defaultValue: '' }),
|
||||
minZoom: schema.number({ defaultValue: 0, min: 0 }),
|
||||
maxZoom: schema.number({ defaultValue: 10 }),
|
||||
tileSize: schema.maybe(schema.number()),
|
||||
subdomains: schema.maybe(schema.arrayOf(schema.string())),
|
||||
errorTileUrl: schema.maybe(schema.string()),
|
||||
tms: schema.maybe(schema.boolean()),
|
||||
reuseTiles: schema.maybe(schema.boolean()),
|
||||
bounds: schema.maybe(schema.arrayOf(schema.number({ min: 2 }))),
|
||||
default: schema.maybe(schema.boolean()),
|
||||
}),
|
||||
});
|
||||
|
||||
export type ConfigSchema = TypeOf<typeof configSchema>;
|
14
src/plugins/tile_map/kibana.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"id": "tileMap",
|
||||
"version": "8.0.0",
|
||||
"kibanaVersion": "kibana",
|
||||
"configPath": ["map", "tilemap"],
|
||||
"ui": true,
|
||||
"server": true,
|
||||
"requiredPlugins": [
|
||||
"visualizations",
|
||||
"expressions",
|
||||
"mapsLegacy",
|
||||
"data"
|
||||
]
|
||||
}
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
@ -23,37 +23,37 @@ import { ImageComparator } from 'test_utils/image_comparator';
|
|||
import dummyESResponse from './dummy_es_response.json';
|
||||
import initial from './initial.png';
|
||||
import blues from './blues.png';
|
||||
import shadedGeohashGrid from './shadedGeohashGrid.png';
|
||||
import shadedGeohashGrid from './shaded_geohash_grid.png';
|
||||
import heatmapRaw from './heatmap_raw.png';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_CATALOGUE from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json';
|
||||
import EMS_CATALOGUE from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_manifest.json';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_FILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_files.json';
|
||||
import EMS_FILES from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_files.json';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_TILES from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json';
|
||||
import EMS_TILES from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_tiles.json';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_bright';
|
||||
import EMS_STYLE_ROAD_MAP_BRIGHT from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_style_bright';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_desaturated';
|
||||
import EMS_STYLE_ROAD_MAP_DESATURATED from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_style_desaturated';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import EMS_STYLE_DARK_MAP from '../../../../../plugins/maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark';
|
||||
import EMS_STYLE_DARK_MAP from '../../../maps_legacy/public/__tests__/map/ems_mocks/sample_style_dark';
|
||||
|
||||
import { createTileMapVisualization } from '../tile_map_visualization';
|
||||
import { createTileMapTypeDefinition } from '../tile_map_type';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { ExprVis } from '../../../../../plugins/visualizations/public/expressions/vis';
|
||||
import { ExprVis } from '../../../visualizations/public/expressions/vis';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { BaseVisType } from '../../../../../plugins/visualizations/public/vis_types/base_vis_type';
|
||||
import { BaseVisType } from '../../../visualizations/public/vis_types/base_vis_type';
|
||||
import {
|
||||
getPrecision,
|
||||
getZoomPrecision,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../../plugins/maps_legacy/public/map/precision';
|
||||
} from '../../../maps_legacy/public/map/precision';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { ServiceSettings } from '../../../../../plugins/maps_legacy/public/map/service_settings';
|
||||
import { ServiceSettings } from '../../../maps_legacy/public/map/service_settings';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { setInjectedVarFunc } from '../../../../../plugins/maps_legacy/public/kibana_services';
|
||||
import { getBaseMapsVis } from '../../../../../plugins/maps_legacy/public';
|
||||
import { setInjectedVarFunc } from '../../../maps_legacy/public/kibana_services';
|
||||
import { getBaseMapsVis } from '../../../maps_legacy/public';
|
||||
|
||||
function mockRawData() {
|
||||
const stack = [dummyESResponse];
|
||||
|
@ -91,24 +91,22 @@ describe('CoordinateMapsVisualizationTest', function() {
|
|||
beforeEach(ngMock.module('kibana'));
|
||||
beforeEach(
|
||||
ngMock.inject((Private, $injector) => {
|
||||
const mapConfig = {
|
||||
emsFileApiUrl: '',
|
||||
emsTileApiUrl: '',
|
||||
emsLandingPageUrl: '',
|
||||
};
|
||||
const tilemapsConfig = {
|
||||
deprecated: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '123',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
setInjectedVarFunc(injectedVar => {
|
||||
switch (injectedVar) {
|
||||
case 'mapConfig':
|
||||
return {
|
||||
emsFileApiUrl: '',
|
||||
emsTileApiUrl: '',
|
||||
emsLandingPageUrl: '',
|
||||
};
|
||||
case 'tilemapsConfig':
|
||||
return {
|
||||
deprecated: {
|
||||
config: {
|
||||
options: {
|
||||
attribution: '123',
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
case 'version':
|
||||
return '123';
|
||||
default:
|
||||
|
@ -125,7 +123,7 @@ describe('CoordinateMapsVisualizationTest', function() {
|
|||
getInjectedVar: () => {},
|
||||
},
|
||||
};
|
||||
const serviceSettings = new ServiceSettings();
|
||||
const serviceSettings = new ServiceSettings(mapConfig, tilemapsConfig);
|
||||
const BaseMapsVisualization = getBaseMapsVis(coreSetupMock, serviceSettings);
|
||||
const uiSettings = $injector.get('config');
|
||||
|
|
@ -20,12 +20,12 @@
|
|||
import expect from '@kbn/expect';
|
||||
import { GeohashLayer } from '../geohash_layer';
|
||||
// import heatmapPng from './heatmap.png';
|
||||
import scaledCircleMarkersPng from './scaledCircleMarkers.png';
|
||||
import scaledCircleMarkersPng from './scaled_circle_markers.png';
|
||||
// import shadedCircleMarkersPng from './shadedCircleMarkers.png';
|
||||
import { ImageComparator } from 'test_utils/image_comparator';
|
||||
import GeoHashSampleData from './dummy_es_response.json';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { KibanaMap } from '../../../../../plugins/maps_legacy/public/map/kibana_map';
|
||||
import { KibanaMap } from '../../../maps_legacy/public/map/kibana_map';
|
||||
|
||||
describe('geohash_layer', function() {
|
||||
let domNode;
|
Before Width: | Height: | Size: 85 KiB After Width: | Height: | Size: 85 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -22,13 +22,8 @@ import { EuiPanel, EuiSpacer } from '@elastic/eui';
|
|||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
|
||||
import {
|
||||
BasicOptions,
|
||||
RangeOption,
|
||||
SelectOption,
|
||||
SwitchOption,
|
||||
} from '../../../../../plugins/charts/public';
|
||||
import { WmsOptions, TileMapVisParams, MapTypes } from '../../../../../plugins/maps_legacy/public';
|
||||
import { BasicOptions, RangeOption, SelectOption, SwitchOption } from '../../../charts/public';
|
||||
import { WmsOptions, TileMapVisParams, MapTypes } from '../../../maps_legacy/public';
|
||||
|
||||
export type TileMapOptionsProps = VisOptionsProps<TileMapVisParams>;
|
||||
|
|
@ -17,10 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import { min, isEqual } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { KibanaMapLayer, MapTypes } from '../../../../plugins/maps_legacy/public';
|
||||
import { L, KibanaMapLayer, MapTypes } from '../../maps_legacy/public';
|
||||
import { HeatmapMarkers } from './markers/heatmap';
|
||||
import { ScaledCirclesMarkers } from './markers/scaled_circles';
|
||||
import { ShadedCirclesMarkers } from './markers/shaded_circles';
|
|
@ -7,4 +7,4 @@
|
|||
// tlmChart__legend--small
|
||||
// tlmChart__legend-isLoading
|
||||
|
||||
@import './tile_map';
|
||||
@import 'tile_map';
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../../core/public';
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { TileMapPlugin as Plugin } from './plugin';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
|
@ -17,8 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import { ScaledCirclesMarkers } from './scaled_circles';
|
||||
import { L } from '../../../maps_legacy/public';
|
||||
|
||||
export class GeohashGridMarkers extends ScaledCirclesMarkers {
|
||||
getMarkerFunction() {
|
|
@ -17,10 +17,10 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
import { EventEmitter } from 'events';
|
||||
import { L } from '../../../maps_legacy/public';
|
||||
|
||||
/**
|
||||
* Map overlay: canvas layer with leaflet.heat plugin
|
||||
|
@ -34,7 +34,7 @@ export class HeatmapMarkers extends EventEmitter {
|
|||
super();
|
||||
this._geojsonFeatureCollection = featureCollection;
|
||||
const points = dataToHeatArray(featureCollection, max);
|
||||
this._leafletLayer = L.heatLayer(points, options);
|
||||
this._leafletLayer = new L.HeatLayer(points, options);
|
||||
this._tooltipFormatter = options.tooltipFormatter;
|
||||
this._zoom = zoom;
|
||||
this._disableTooltips = false;
|
|
@ -17,13 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
import $ from 'jquery';
|
||||
import { EventEmitter } from 'events';
|
||||
import { colorUtil } from '../../../../../plugins/maps_legacy/public';
|
||||
import { truncatedColorMaps } from '../../../../../plugins/charts/public';
|
||||
import { L, colorUtil } from '../../../maps_legacy/public';
|
||||
import { truncatedColorMaps } from '../../../charts/public';
|
||||
|
||||
export class ScaledCirclesMarkers extends EventEmitter {
|
||||
constructor(
|
|
@ -17,9 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import _ from 'lodash';
|
||||
import { ScaledCirclesMarkers } from './scaled_circles';
|
||||
import { L } from '../../../maps_legacy/public';
|
||||
|
||||
export class ShadedCirclesMarkers extends ScaledCirclesMarkers {
|
||||
getMarkerFunction() {
|
|
@ -22,9 +22,9 @@ import {
|
|||
Plugin,
|
||||
PluginInitializerContext,
|
||||
IUiSettingsClient,
|
||||
} from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
} from 'kibana/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
// TODO: Determine why visualizations don't populate without this
|
||||
import 'angular-sanitize';
|
||||
|
||||
|
@ -32,7 +32,13 @@ import 'angular-sanitize';
|
|||
import { createTileMapFn } from './tile_map_fn';
|
||||
// @ts-ignore
|
||||
import { createTileMapTypeDefinition } from './tile_map_type';
|
||||
import { getBaseMapsVis, MapsLegacyPluginSetup } from '../../../../plugins/maps_legacy/public';
|
||||
import { getBaseMapsVis, MapsLegacyPluginSetup } from '../../maps_legacy/public';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
import { setFormatService, setQueryService } from './services';
|
||||
|
||||
export interface TileMapConfigType {
|
||||
tilemap: any;
|
||||
}
|
||||
|
||||
/** @private */
|
||||
interface TileMapVisualizationDependencies {
|
||||
|
@ -50,7 +56,18 @@ export interface TileMapPluginSetupDependencies {
|
|||
}
|
||||
|
||||
/** @internal */
|
||||
export class TileMapPlugin implements Plugin<Promise<void>, void> {
|
||||
export interface TileMapPluginStartDependencies {
|
||||
data: DataPublicPluginStart;
|
||||
}
|
||||
|
||||
export interface TileMapPluginSetup {
|
||||
config: any;
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface TileMapPluginStart {}
|
||||
|
||||
/** @internal */
|
||||
export class TileMapPlugin implements Plugin<TileMapPluginSetup, TileMapPluginStart> {
|
||||
initializerContext: PluginInitializerContext;
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext) {
|
||||
|
@ -72,9 +89,16 @@ export class TileMapPlugin implements Plugin<Promise<void>, void> {
|
|||
expressions.registerFunction(() => createTileMapFn(visualizationDependencies));
|
||||
|
||||
visualizations.createBaseVisualization(createTileMapTypeDefinition(visualizationDependencies));
|
||||
|
||||
const config = this.initializerContext.config.get<TileMapConfigType>();
|
||||
return {
|
||||
config,
|
||||
};
|
||||
}
|
||||
|
||||
public start(core: CoreStart) {
|
||||
// nothing to do here yet
|
||||
public start(core: CoreStart, { data }: TileMapPluginStartDependencies) {
|
||||
setFormatService(data.fieldFormats);
|
||||
setQueryService(data.query);
|
||||
return {};
|
||||
}
|
||||
}
|
29
src/plugins/tile_map/public/services.ts
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { createGetterSetter } from '../../kibana_utils/public';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
|
||||
export const [getFormatService, setFormatService] = createGetterSetter<
|
||||
DataPublicPluginStart['fieldFormats']
|
||||
>('vislib data.fieldFormats');
|
||||
|
||||
export const [getQueryService, setQueryService] = createGetterSetter<
|
||||
DataPublicPluginStart['query']
|
||||
>('Query');
|
|
@ -16,7 +16,7 @@
|
|||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
import { convertToGeoJson } from '../../../../plugins/maps_legacy/public';
|
||||
import { convertToGeoJson } from '../../maps_legacy/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
export const createTileMapFn = () => ({
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
import React from 'react';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { convertToGeoJson, MapTypes } from '../../../../plugins/maps_legacy/public';
|
||||
import { Schemas } from '../../../../plugins/vis_default_editor/public';
|
||||
import { convertToGeoJson, MapTypes } from '../../maps_legacy/public';
|
||||
import { Schemas } from '../../vis_default_editor/public';
|
||||
import { createTileMapVisualization } from './tile_map_visualization';
|
||||
import { TileMapOptions } from './components/tile_map_options';
|
||||
import { supportsCssFilters } from './css_filters';
|
||||
import { truncatedColorSchemas } from '../../../../plugins/charts/public';
|
||||
import { truncatedColorSchemas } from '../../charts/public';
|
||||
|
||||
export function createTileMapTypeDefinition(dependencies) {
|
||||
const CoordinateMapsVisualization = createTileMapVisualization(dependencies);
|
|
@ -19,13 +19,8 @@
|
|||
|
||||
import { get } from 'lodash';
|
||||
import { GeohashLayer } from './geohash_layer';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { getFormat } from '../../../ui/public/visualize/loader/pipeline_helpers/utilities';
|
||||
import {
|
||||
scaleBounds,
|
||||
geoContains,
|
||||
mapTooltipProvider,
|
||||
} from '../../../../plugins/maps_legacy/public';
|
||||
import { getFormatService, getQueryService } from './services';
|
||||
import { scaleBounds, geoContains, mapTooltipProvider } from '../../maps_legacy/public';
|
||||
import { tooltipFormatter } from './tooltip_formatter';
|
||||
|
||||
export const createTileMapVisualization = dependencies => {
|
||||
|
@ -183,7 +178,9 @@ export const createTileMapVisualization = dependencies => {
|
|||
const newParams = this._getMapsParams();
|
||||
const metricDimension = this._params.dimensions.metric;
|
||||
const metricLabel = metricDimension ? metricDimension.label : '';
|
||||
const metricFormat = getFormat(metricDimension && metricDimension.format);
|
||||
const metricFormat = getFormatService().deserialize(
|
||||
metricDimension && metricDimension.format
|
||||
);
|
||||
|
||||
return {
|
||||
label: metricLabel,
|
||||
|
@ -213,7 +210,7 @@ export const createTileMapVisualization = dependencies => {
|
|||
filter[filterName] = { ignore_unmapped: true };
|
||||
filter[filterName][field] = filterData;
|
||||
|
||||
const { filterManager } = npStart.plugins.data.query;
|
||||
const { filterManager } = getQueryService();
|
||||
filterManager.addFilters([filter]);
|
||||
|
||||
this.vis.updateState();
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
|
||||
// eslint-disable-next-line
|
||||
import { functionWrapper } from '../../../../plugins/expressions/common/expression_functions/specs/tests/utils';
|
||||
import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils';
|
||||
import { createTileMapFn } from './tile_map_fn';
|
||||
|
||||
jest.mock('ui/new_platform');
|
||||
jest.mock('../../../../plugins/maps_legacy/public', () => ({
|
||||
jest.mock('../../maps_legacy/public', () => ({
|
||||
convertToGeoJson: jest.fn().mockReturnValue({
|
||||
featureCollection: {
|
||||
type: 'FeatureCollection',
|
||||
|
@ -37,7 +36,7 @@ jest.mock('../../../../plugins/maps_legacy/public', () => ({
|
|||
}),
|
||||
}));
|
||||
|
||||
import { convertToGeoJson } from '../../../../plugins/maps_legacy/public';
|
||||
import { convertToGeoJson } from '../../maps_legacy/public';
|
||||
|
||||
describe('interpreter/functions#tilemap', () => {
|
||||
const fn = functionWrapper(createTileMapFn());
|
|
@ -17,19 +17,19 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
import { configSchema, ConfigSchema } from '../config';
|
||||
|
||||
import { TileMapPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
|
||||
const plugins: Readonly<TileMapPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
mapsLegacy: npSetup.plugins.mapsLegacy,
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
exposeToBrowser: {
|
||||
url: true,
|
||||
deprecated: true,
|
||||
options: true,
|
||||
},
|
||||
schema: configSchema,
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
||||
export const setup = pluginInstance.setup(npSetup.core, plugins);
|
||||
export const start = pluginInstance.start(npStart.core);
|
||||
export const plugin = () => ({
|
||||
setup() {},
|
||||
start() {},
|
||||
});
|
|
@ -27,6 +27,7 @@ import {
|
|||
setInjectedVars,
|
||||
setUISettings,
|
||||
setKibanaMapFactory,
|
||||
setMapsLegacyConfig,
|
||||
} from './services';
|
||||
|
||||
import { createVegaFn } from './vega_fn';
|
||||
|
@ -76,6 +77,7 @@ export class VegaPlugin implements Plugin<Promise<void>, void> {
|
|||
});
|
||||
setUISettings(core.uiSettings);
|
||||
setKibanaMapFactory(getKibanaMapFactoryProvider(core));
|
||||
setMapsLegacyConfig(mapsLegacy.config);
|
||||
|
||||
const visualizationDependencies: Readonly<VegaVisualizationDependencies> = {
|
||||
core,
|
||||
|
|
|
@ -21,6 +21,7 @@ import { SavedObjectsStart } from 'kibana/public';
|
|||
import { NotificationsStart, IUiSettingsClient } from 'src/core/public';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
import { createGetterSetter } from '../../kibana_utils/public';
|
||||
import { MapsLegacyConfigType } from '../../maps_legacy/public';
|
||||
|
||||
export const [getData, setData] = createGetterSetter<DataPublicPluginStart>('Data');
|
||||
|
||||
|
@ -43,6 +44,10 @@ export const [getInjectedVars, setInjectedVars] = createGetterSetter<{
|
|||
emsTileLayerId: unknown;
|
||||
}>('InjectedVars');
|
||||
|
||||
export const [getMapsLegacyConfig, setMapsLegacyConfig] = createGetterSetter<MapsLegacyConfigType>(
|
||||
'MapsLegacyConfig'
|
||||
);
|
||||
|
||||
export const getEsShardTimeout = () => getInjectedVars().esShardTimeout;
|
||||
export const getEnableExternalUrls = () => getInjectedVars().enableExternalUrls;
|
||||
export const getEmsTileLayerId = () => getInjectedVars().emsTileLayerId;
|
||||
export const getEmsTileLayerId = () => getMapsLegacyConfig().emsTileLayerId;
|
||||
|
|
|
@ -17,9 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import L from 'leaflet';
|
||||
import 'leaflet-vega';
|
||||
import { KibanaMapLayer } from '../../../maps_legacy/public';
|
||||
import { KibanaMapLayer, L } from '../../../maps_legacy/public';
|
||||
|
||||
export class VegaMapLayer extends KibanaMapLayer {
|
||||
constructor(spec, options) {
|
||||
|
@ -28,7 +26,6 @@ export class VegaMapLayer extends KibanaMapLayer {
|
|||
// Used by super.getAttributions()
|
||||
this._attribution = options.attribution;
|
||||
delete options.attribution;
|
||||
|
||||
this._leafletLayer = L.vega(spec, options);
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,7 @@ export class VegaMapView extends VegaBaseView {
|
|||
// let maxBounds = null;
|
||||
// if (mapConfig.maxBounds) {
|
||||
// const b = mapConfig.maxBounds;
|
||||
// eslint-disable-next-line no-undef
|
||||
// maxBounds = L.latLngBounds(L.latLng(b[1], b[0]), L.latLng(b[3], b[2]));
|
||||
// }
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import 'uiExports/search';
|
|||
import 'uiExports/shareContextMenuExtensions';
|
||||
import _ from 'lodash';
|
||||
import 'ui/autoload/all';
|
||||
import 'leaflet';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
import { localApplicationService } from 'plugins/kibana/local_application_service';
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import mappings from './mappings.json';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { resolve } from 'path';
|
||||
|
@ -39,23 +38,13 @@ export function maps(kibana) {
|
|||
},
|
||||
injectDefaultVars(server) {
|
||||
const serverConfig = server.config();
|
||||
const mapConfig = serverConfig.get('map');
|
||||
|
||||
return {
|
||||
showMapVisualizationTypes: serverConfig.get('xpack.maps.showMapVisualizationTypes'),
|
||||
showMapsInspectorAdapter: serverConfig.get('xpack.maps.showMapsInspectorAdapter'),
|
||||
enableVectorTiles: serverConfig.get('xpack.maps.enableVectorTiles'),
|
||||
preserveDrawingBuffer: serverConfig.get('xpack.maps.preserveDrawingBuffer'),
|
||||
isEmsEnabled: mapConfig.includeElasticMapsService,
|
||||
emsFontLibraryUrl: mapConfig.emsFontLibraryUrl,
|
||||
emsTileLayerId: mapConfig.emsTileLayerId,
|
||||
proxyElasticMapsServiceInMaps: mapConfig.proxyElasticMapsServiceInMaps,
|
||||
emsFileApiUrl: mapConfig.emsFileApiUrl,
|
||||
emsTileApiUrl: mapConfig.emsTileApiUrl,
|
||||
emsLandingPageUrl: mapConfig.emsLandingPageUrl,
|
||||
kbnPkgVersion: serverConfig.get('pkg.version'),
|
||||
regionmapLayers: _.get(mapConfig, 'regionmap.layers', []),
|
||||
tilemap: _.get(mapConfig, 'tilemap', {}),
|
||||
};
|
||||
},
|
||||
styleSheetPaths: `${__dirname}/public/index.scss`,
|
||||
|
@ -112,14 +101,12 @@ export function maps(kibana) {
|
|||
licensing: newPlatformPlugins.licensing,
|
||||
home: newPlatformPlugins.home,
|
||||
usageCollection: newPlatformPlugins.usageCollection,
|
||||
mapsLegacy: newPlatformPlugins.mapsLegacy,
|
||||
};
|
||||
|
||||
// legacy dependencies
|
||||
const __LEGACY = {
|
||||
config: server.config,
|
||||
mapConfig() {
|
||||
return server.config().get('map');
|
||||
},
|
||||
route: server.route.bind(server),
|
||||
plugins: {
|
||||
elasticsearch: server.plugins.elasticsearch,
|
||||
|
@ -132,8 +119,8 @@ export function maps(kibana) {
|
|||
getInjectedUiAppVars: server.getInjectedUiAppVars,
|
||||
};
|
||||
|
||||
const mapPluginSetup = new MapPlugin().setup(coreSetup, pluginsSetup, __LEGACY);
|
||||
server.expose('getMapConfig', mapPluginSetup.getMapConfig);
|
||||
const mapPlugin = new MapPlugin();
|
||||
mapPlugin.setup(coreSetup, pluginsSetup, __LEGACY);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -19,8 +19,9 @@ import { emsBoundariesSpecProvider } from './tutorials/ems';
|
|||
|
||||
export class MapPlugin {
|
||||
setup(core, plugins, __LEGACY) {
|
||||
const { featuresPlugin, home, licensing, usageCollection } = plugins;
|
||||
const { featuresPlugin, home, licensing, usageCollection, mapsLegacy } = plugins;
|
||||
let routesInitialized = false;
|
||||
const mapConfig = mapsLegacy.config;
|
||||
|
||||
featuresPlugin.registerFeature({
|
||||
id: APP_ID,
|
||||
|
@ -58,7 +59,7 @@ export class MapPlugin {
|
|||
const { state } = license.check('maps', 'basic');
|
||||
if (state === 'valid' && !routesInitialized) {
|
||||
routesInitialized = true;
|
||||
initRoutes(__LEGACY, license.uid);
|
||||
initRoutes(__LEGACY, license.uid, mapConfig);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -134,7 +135,7 @@ export class MapPlugin {
|
|||
home.tutorials.registerTutorial(
|
||||
emsBoundariesSpecProvider({
|
||||
prependBasePath: core.http.basePath.prepend,
|
||||
emsLandingPageUrl: __LEGACY.mapConfig().emsLandingPageUrl,
|
||||
emsLandingPageUrl: mapConfig.emsLandingPageUrl,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
@ -142,11 +143,5 @@ export class MapPlugin {
|
|||
__LEGACY.injectUiAppVars(APP_ID, async () => {
|
||||
return await __LEGACY.getInjectedUiAppVars('kibana');
|
||||
});
|
||||
|
||||
return {
|
||||
getMapConfig() {
|
||||
return __LEGACY.mapConfig();
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,8 @@ import Boom from 'boom';
|
|||
|
||||
const ROOT = `/${GIS_API_PATH}`;
|
||||
|
||||
export function initRoutes(server, licenseUid) {
|
||||
export function initRoutes(server, licenseUid, mapConfig) {
|
||||
const serverConfig = server.config();
|
||||
const mapConfig = serverConfig.get('map');
|
||||
|
||||
let emsClient;
|
||||
if (mapConfig.includeElasticMapsService) {
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
"uiActions",
|
||||
"navigation",
|
||||
"visualizations",
|
||||
"embeddable"
|
||||
"embeddable",
|
||||
"mapsLegacy"
|
||||
],
|
||||
"ui": true
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import { KibanaTilemapSource } from '../layers/sources/kibana_tilemap_source';
|
|||
import { TileLayer } from '../layers/tile_layer';
|
||||
import { EMSTMSSource } from '../layers/sources/ems_tms_source';
|
||||
import { VectorTileLayer } from '../layers/vector_tile_layer';
|
||||
import { getInjectedVarFunc } from '../kibana_services';
|
||||
import { getIsEmsEnabled } from '../kibana_services';
|
||||
import { getKibanaTileMap } from '../meta';
|
||||
|
||||
export function getInitialLayers(layerListJSON, initialLayers = []) {
|
||||
|
@ -32,7 +32,7 @@ export function getInitialLayers(layerListJSON, initialLayers = []) {
|
|||
return [layerDescriptor, ...initialLayers];
|
||||
}
|
||||
|
||||
const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true);
|
||||
const isEmsEnabled = getIsEmsEnabled();
|
||||
if (isEmsEnabled) {
|
||||
const layerDescriptor = VectorTileLayer.createDescriptor({
|
||||
sourceDescriptor: EMSTMSSource.createDescriptor({ isAutoSelect: true }),
|
||||
|
|
|
@ -65,6 +65,7 @@ describe('EMS is enabled', () => {
|
|||
require('../meta').getKibanaTileMap = () => {
|
||||
return null;
|
||||
};
|
||||
require('../kibana_services').getIsEmsEnabled = () => true;
|
||||
require('../kibana_services').getInjectedVarFunc = () => key => {
|
||||
switch (key) {
|
||||
case 'emsTileLayerId':
|
||||
|
@ -73,8 +74,6 @@ describe('EMS is enabled', () => {
|
|||
desaturated: 'road_map_desaturated',
|
||||
dark: 'dark_map',
|
||||
};
|
||||
case 'isEmsEnabled':
|
||||
return true;
|
||||
default:
|
||||
throw new Error(`Unexpected call to getInjectedVarFunc with key ${key}`);
|
||||
}
|
||||
|
@ -109,15 +108,7 @@ describe('EMS is not enabled', () => {
|
|||
require('../meta').getKibanaTileMap = () => {
|
||||
return null;
|
||||
};
|
||||
|
||||
require('../kibana_services').getInjectedVarFunc = () => key => {
|
||||
switch (key) {
|
||||
case 'isEmsEnabled':
|
||||
return false;
|
||||
default:
|
||||
throw new Error(`Unexpected call to getInjectedVarFunc with key ${key}`);
|
||||
}
|
||||
};
|
||||
require('../kibana_services').getIsEmsEnabled = () => false;
|
||||
});
|
||||
|
||||
it('Should return empty layer list since there are no configured tile layers', () => {
|
||||
|
|
11
x-pack/plugins/maps/public/kibana_services.d.ts
vendored
|
@ -4,6 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { IIndexPattern, DataPublicPluginStart } from 'src/plugins/data/public';
|
||||
import _ from 'lodash';
|
||||
|
||||
export function getLicenseId(): any;
|
||||
export function getInspector(): any;
|
||||
|
@ -30,6 +31,15 @@ export function getCore(): any;
|
|||
export function getNavigation(): any;
|
||||
export function getCoreI18n(): any;
|
||||
export function getSearchService(): DataPublicPluginStart['search'];
|
||||
export function getMapConfig(): any;
|
||||
export function getIsEmsEnabled(): any;
|
||||
export function getEmsFontLibraryUrl(): any;
|
||||
export function getEmsTileLayerId(): any;
|
||||
export function getEmsFileApiUrl(): any;
|
||||
export function getEmsTileApiUrl(): any;
|
||||
export function getEmsLandingPageUrl(): any;
|
||||
export function getRegionmapLayers(): any;
|
||||
export function getTilemap(): any;
|
||||
|
||||
export function setLicenseId(args: unknown): void;
|
||||
export function setInspector(args: unknown): void;
|
||||
|
@ -54,3 +64,4 @@ export function setCore(args: unknown): void;
|
|||
export function setNavigation(args: unknown): void;
|
||||
export function setCoreI18n(args: unknown): void;
|
||||
export function setSearchService(args: DataPublicPluginStart['search']): void;
|
||||
export function setMapConfig(args: unknown): void;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { esFilters, search } from '../../../../src/plugins/data/public';
|
||||
import _ from 'lodash';
|
||||
|
||||
export const SPATIAL_FILTER_TYPE = esFilters.FILTERS.SPATIAL_FILTER;
|
||||
const { getRequestInspectorStats, getResponseInspectorStats } = search;
|
||||
|
@ -139,3 +140,16 @@ export const getCoreI18n = () => coreI18n;
|
|||
let dataSearchService;
|
||||
export const setSearchService = searchService => (dataSearchService = searchService);
|
||||
export const getSearchService = () => dataSearchService;
|
||||
|
||||
let mapConfig;
|
||||
export const setMapConfig = config => (mapConfig = config);
|
||||
export const getMapConfig = () => mapConfig;
|
||||
|
||||
export const getIsEmsEnabled = () => getMapConfig().includeElasticMapsService;
|
||||
export const getEmsFontLibraryUrl = () => getMapConfig().emsFontLibraryUrl;
|
||||
export const getEmsTileLayerId = () => getMapConfig().emsTileLayerId;
|
||||
export const getEmsFileApiUrl = () => getMapConfig().emsFileApiUrl;
|
||||
export const getEmsTileApiUrl = () => getMapConfig().emsTileApiUrl;
|
||||
export const getEmsLandingPageUrl = () => getMapConfig().emsLandingPageUrl;
|
||||
export const getRegionmapLayers = () => _.get(getMapConfig(), 'regionmap.layers', []);
|
||||
export const getTilemap = () => _.get(getMapConfig(), 'tilemap', []);
|
||||
|
|
|
@ -10,13 +10,13 @@ import { VectorLayer } from '../../vector_layer';
|
|||
import { LayerWizard, RenderWizardArguments } from '../../layer_wizard_registry';
|
||||
import { EMSFileCreateSourceEditor } from './create_source_editor';
|
||||
import { EMSFileSource, sourceTitle } from './ems_file_source';
|
||||
import { EMSFileSourceDescriptor } from '../../../../common/descriptor_types';
|
||||
// @ts-ignore
|
||||
import { isEmsEnabled } from '../../../meta';
|
||||
import { getIsEmsEnabled } from '../../../kibana_services';
|
||||
import { EMSFileSourceDescriptor } from '../../../../common/descriptor_types';
|
||||
|
||||
export const emsBoundariesLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
return isEmsEnabled();
|
||||
return getIsEmsEnabled();
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.emsFileDescription', {
|
||||
defaultMessage: 'Administrative boundaries from Elastic Maps Service',
|
||||
|
|
|
@ -12,12 +12,11 @@ import { EMSTMSSource, sourceTitle } from './ems_tms_source';
|
|||
import { VectorTileLayer } from '../../vector_tile_layer';
|
||||
// @ts-ignore
|
||||
import { TileServiceSelect } from './tile_service_select';
|
||||
// @ts-ignore
|
||||
import { isEmsEnabled } from '../../../meta';
|
||||
import { getIsEmsEnabled } from '../../../kibana_services';
|
||||
|
||||
export const emsBaseMapLayerWizardConfig: LayerWizard = {
|
||||
checkVisibility: () => {
|
||||
return isEmsEnabled();
|
||||
return getIsEmsEnabled();
|
||||
},
|
||||
description: i18n.translate('xpack.maps.source.emsTileDescription', {
|
||||
defaultMessage: 'Tile map service from Elastic Maps Service',
|
||||
|
|
|
@ -7,13 +7,12 @@
|
|||
import _ from 'lodash';
|
||||
import React from 'react';
|
||||
import { AbstractTMSSource } from '../tms_source';
|
||||
|
||||
import { getEMSClient } from '../../../meta';
|
||||
import { UpdateSourceEditor } from './update_source_editor';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getDataSourceLabel } from '../../../../common/i18n_getters';
|
||||
import { SOURCE_TYPES } from '../../../../common/constants';
|
||||
import { getInjectedVarFunc, getUiSettings } from '../../../kibana_services';
|
||||
import { getEmsTileLayerId, getUiSettings } from '../../../kibana_services';
|
||||
import { registerSource } from '../source_registry';
|
||||
|
||||
export const sourceTitle = i18n.translate('xpack.maps.source.emsTileTitle', {
|
||||
|
@ -125,7 +124,7 @@ export class EMSTMSSource extends AbstractTMSSource {
|
|||
}
|
||||
|
||||
const isDarkMode = getUiSettings().get('theme:darkMode', false);
|
||||
const emsTileLayerId = getInjectedVarFunc()('emsTileLayerId');
|
||||
const emsTileLayerId = getEmsTileLayerId();
|
||||
return isDarkMode ? emsTileLayerId.dark : emsTileLayerId.bright;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,10 +5,11 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { getInjectedVarFunc } from '../../kibana_services';
|
||||
// @ts-ignore
|
||||
import { getIsEmsEnabled } from '../../kibana_services';
|
||||
|
||||
export function getEmsUnavailableMessage(): string {
|
||||
const isEmsEnabled = getInjectedVarFunc()('isEmsEnabled', true);
|
||||
const isEmsEnabled = getIsEmsEnabled();
|
||||
if (isEmsEnabled) {
|
||||
return i18n.translate('xpack.maps.source.ems.noAccessDescription', {
|
||||
defaultMessage:
|
||||
|
|
|
@ -13,17 +13,27 @@ import {
|
|||
} from '../common/constants';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { EMSClient } from '@elastic/ems-client';
|
||||
import { getInjectedVarFunc, getLicenseId } from './kibana_services';
|
||||
import {
|
||||
getInjectedVarFunc,
|
||||
getLicenseId,
|
||||
getIsEmsEnabled,
|
||||
getRegionmapLayers,
|
||||
getTilemap,
|
||||
getEmsFileApiUrl,
|
||||
getEmsTileApiUrl,
|
||||
getEmsLandingPageUrl,
|
||||
getEmsFontLibraryUrl,
|
||||
} from './kibana_services';
|
||||
import fetch from 'node-fetch';
|
||||
|
||||
const GIS_API_RELATIVE = `../${GIS_API_PATH}`;
|
||||
|
||||
export function getKibanaRegionList() {
|
||||
return getInjectedVarFunc()('regionmapLayers');
|
||||
return getRegionmapLayers();
|
||||
}
|
||||
|
||||
export function getKibanaTileMap() {
|
||||
return getInjectedVarFunc()('tilemap');
|
||||
return getTilemap();
|
||||
}
|
||||
|
||||
function relativeToAbsolute(url) {
|
||||
|
@ -36,15 +46,12 @@ function fetchFunction(...args) {
|
|||
return fetch(...args);
|
||||
}
|
||||
|
||||
export function isEmsEnabled() {
|
||||
return getInjectedVarFunc()('isEmsEnabled', true);
|
||||
}
|
||||
|
||||
let emsClient = null;
|
||||
let latestLicenseId = null;
|
||||
export function getEMSClient() {
|
||||
if (!emsClient) {
|
||||
if (isEmsEnabled()) {
|
||||
const isEmsEnabled = getIsEmsEnabled();
|
||||
if (isEmsEnabled) {
|
||||
const proxyElasticMapsServiceInMaps = getInjectedVarFunc()(
|
||||
'proxyElasticMapsServiceInMaps',
|
||||
false
|
||||
|
@ -52,10 +59,10 @@ export function getEMSClient() {
|
|||
const proxyPath = '';
|
||||
const tileApiUrl = proxyElasticMapsServiceInMaps
|
||||
? relativeToAbsolute(`${GIS_API_RELATIVE}/${EMS_TILES_CATALOGUE_PATH}`)
|
||||
: getInjectedVarFunc()('emsTileApiUrl');
|
||||
: getEmsTileApiUrl();
|
||||
const fileApiUrl = proxyElasticMapsServiceInMaps
|
||||
? relativeToAbsolute(`${GIS_API_RELATIVE}/${EMS_FILES_CATALOGUE_PATH}`)
|
||||
: getInjectedVarFunc()('emsFileApiUrl');
|
||||
: getEmsFileApiUrl();
|
||||
|
||||
emsClient = new EMSClient({
|
||||
language: i18n.getLocale(),
|
||||
|
@ -63,7 +70,7 @@ export function getEMSClient() {
|
|||
appName: EMS_APP_NAME,
|
||||
tileApiUrl,
|
||||
fileApiUrl,
|
||||
landingPageUrl: getInjectedVarFunc()('emsLandingPageUrl'),
|
||||
landingPageUrl: getEmsLandingPageUrl(),
|
||||
fetchFunction: fetchFunction, //import this from client-side, so the right instance is returned (bootstrapped from common/* would not work
|
||||
proxyPath,
|
||||
});
|
||||
|
@ -89,13 +96,13 @@ export function getEMSClient() {
|
|||
}
|
||||
|
||||
export function getGlyphUrl() {
|
||||
if (!isEmsEnabled()) {
|
||||
if (!getIsEmsEnabled()) {
|
||||
return '';
|
||||
}
|
||||
return getInjectedVarFunc()('proxyElasticMapsServiceInMaps', false)
|
||||
? relativeToAbsolute(`../${GIS_API_PATH}/${EMS_TILES_CATALOGUE_PATH}/${EMS_GLYPHS_PATH}`) +
|
||||
`/{fontstack}/{range}`
|
||||
: getInjectedVarFunc()('emsFontLibraryUrl', true);
|
||||
: getEmsFontLibraryUrl();
|
||||
}
|
||||
|
||||
export function isRetina() {
|
||||
|
|
|
@ -25,6 +25,11 @@ describe('default use without proxy', () => {
|
|||
require('./kibana_services').getLicenseId = () => {
|
||||
return 'foobarlicenseid';
|
||||
};
|
||||
require('./kibana_services').getIsEmsEnabled = () => true;
|
||||
require('./kibana_services').getEmsTileLayerId = () => '123';
|
||||
require('./kibana_services').getEmsFileApiUrl = () => 'https://file-api';
|
||||
require('./kibana_services').getEmsTileApiUrl = () => 'https://tile-api';
|
||||
require('./kibana_services').getEmsLandingPageUrl = () => 'http://test.com';
|
||||
});
|
||||
|
||||
it('should construct EMSClient with absolute file and tile API urls', async () => {
|
||||
|
|
|
@ -32,6 +32,7 @@ import {
|
|||
setUiSettings,
|
||||
setVisualizations,
|
||||
setSearchService,
|
||||
setMapConfig,
|
||||
} from './kibana_services';
|
||||
import { featureCatalogueEntry } from './feature_catalogue_entry';
|
||||
// @ts-ignore
|
||||
|
@ -47,12 +48,13 @@ export interface MapsPluginSetupDependencies {
|
|||
home: HomePublicPluginSetup;
|
||||
visualizations: VisualizationsSetup;
|
||||
embeddable: EmbeddableSetup;
|
||||
mapsLegacy: { config: unknown };
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface MapsPluginStartDependencies {}
|
||||
|
||||
export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => {
|
||||
const { licensing } = plugins;
|
||||
const { licensing, mapsLegacy } = plugins;
|
||||
const { injectedMetadata, uiSettings, http, notifications } = core;
|
||||
if (licensing) {
|
||||
licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid));
|
||||
|
@ -63,6 +65,7 @@ export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => {
|
|||
setInjectedVarFunc(injectedMetadata.getInjectedVar);
|
||||
setVisualizations(plugins.visualizations);
|
||||
setUiSettings(uiSettings);
|
||||
setMapConfig(mapsLegacy.config);
|
||||
};
|
||||
|
||||
export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => {
|
||||
|
|