Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Enable all zoom levels for all users #96093

Merged
merged 11 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@
/x-pack/test/visual_regression/tests/maps/index.js @elastic/kibana-gis
#CC# /src/plugins/maps_legacy/ @elastic/kibana-gis
#CC# /x-pack/plugins/file_upload @elastic/kibana-gis
#CC# /x-pack/plugins/maps_legacy_licensing @elastic/kibana-gis
/src/plugins/tile_map/ @elastic/kibana-gis
/src/plugins/region_map/ @elastic/kibana-gis

Expand Down
4 changes: 0 additions & 4 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,6 @@ using the CURL scripts in the scripts folder.
|Visualize geo data from Elasticsearch or 3rd party geo-services.


|{kib-repo}blob/{branch}/x-pack/plugins/maps_legacy_licensing/README.md[mapsLegacyLicensing]
|This plugin provides access to the detailed tile map services from Elastic.


|{kib-repo}blob/{branch}/x-pack/plugins/ml/readme.md[ml]
|This plugin provides access to the machine learning features provided by
Elastic.
Expand Down
1 change: 0 additions & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ pageLoadAssetSize:
management: 46112
maps: 80000
mapsLegacy: 87859
mapsLegacyLicensing: 20214
ml: 82187
monitoring: 80000
navigation: 37269
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,43 +103,8 @@ describe('service_settings (FKA tile_map test)', function () {
expect(tmsService.attribution.includes('OpenStreetMap')).toEqual(true);
});

describe('modify - url', function () {
let tilemapServices;

describe('tms mods', function () {
let serviceSettings;
async function assertQuery(expected) {
const attrs = await serviceSettings.getAttributesForTMSLayer(tilemapServices[0]);
const urlObject = url.parse(attrs.url, true);
Object.keys(expected).forEach((key) => {
expect(urlObject.query[key]).toEqual(expected[key]);
});
}

it('accepts an object', async () => {
serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'bar' });
});

it('merged additions with previous values', async () => {
// ensure that changes are always additive
serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
serviceSettings.setQueryParams({ bar: 'stool' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'bar', bar: 'stool' });
});

it('overwrites conflicting previous values', async () => {
serviceSettings = makeServiceSettings();
// ensure that conflicts are overwritten
serviceSettings.setQueryParams({ foo: 'bar' });
serviceSettings.setQueryParams({ bar: 'stool' });
serviceSettings.setQueryParams({ foo: 'tstool' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'tstool', bar: 'stool' });
});

it('should merge in tilemap url', async () => {
serviceSettings = makeServiceSettings(
Expand All @@ -161,7 +126,7 @@ describe('service_settings (FKA tile_map test)', function () {
id: 'road_map',
name: 'Road Map - Bright',
url:
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3',
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl',
minZoom: 0,
maxZoom: 10,
attribution:
Expand Down Expand Up @@ -208,19 +173,19 @@ describe('service_settings (FKA tile_map test)', function () {
);

expect(desaturationFalse.url).toEqual(
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(desaturationFalse.maxZoom).toEqual(10);
expect(desaturationTrue.url).toEqual(
'https://tiles.foobar/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(desaturationTrue.maxZoom).toEqual(18);
expect(darkThemeDesaturationFalse.url).toEqual(
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(darkThemeDesaturationFalse.maxZoom).toEqual(22);
expect(darkThemeDesaturationTrue.url).toEqual(
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3&license=sspl'
);
expect(darkThemeDesaturationTrue.maxZoom).toEqual(22);
});
Expand Down Expand Up @@ -264,14 +229,13 @@ describe('service_settings (FKA tile_map test)', function () {
describe('File layers', function () {
it('should load manifest (all props)', async function () {
const serviceSettings = makeServiceSettings();
serviceSettings.setQueryParams({ foo: 'bar' });
const fileLayers = await serviceSettings.getFileLayers();
expect(fileLayers.length).toEqual(19);
const assertions = fileLayers.map(async function (fileLayer) {
expect(fileLayer.origin).toEqual(ORIGIN.EMS);
const fileUrl = await serviceSettings.getUrlForRegionLayer(fileLayer);
const urlObject = url.parse(fileUrl, true);
Object.keys({ foo: 'bar', elastic_tile_service_tos: 'agree' }).forEach((key) => {
Object.keys({ elastic_tile_service_tos: 'agree' }).forEach((key) => {
expect(typeof urlObject.query[key]).toEqual('string');
});
});
Expand Down
17 changes: 3 additions & 14 deletions src/plugins/maps_ems/public/service_settings/service_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class ServiceSettings implements IServiceSettings {
private readonly _mapConfig: MapsEmsConfig;
private readonly _tilemapsConfig: TileMapConfig;
private readonly _hasTmsConfigured: boolean;
private _showZoomMessage: boolean;
private readonly _emsClient: EMSClient;
private readonly tmsOptionsFromConfig: any;

Expand All @@ -31,7 +30,6 @@ export class ServiceSettings implements IServiceSettings {
this._tilemapsConfig = tilemapsConfig;
this._hasTmsConfigured = typeof tilemapsConfig.url === 'string' && tilemapsConfig.url !== '';

this._showZoomMessage = true;
this._emsClient = new EMSClient({
language: i18n.getLocale(),
appVersion: getKibanaVersion(),
Expand All @@ -45,6 +43,9 @@ export class ServiceSettings implements IServiceSettings {
return fetch(...args);
},
});
// any kibana user, regardless of distribution, should get all zoom levels
// use `sspl` license to indicate this
this._emsClient.addQueryParams({ license: 'sspl' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe out of scope for this PR, but should we consider adding a license parameter to the EMSClient constructor in the @elastic/ems-client library?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, let's do that in separate, since it requires upstream change. I can create a separate PR for the ems-client for this.


const markdownIt = new MarkdownIt({
html: false,
Expand All @@ -58,18 +59,6 @@ export class ServiceSettings implements IServiceSettings {
});
}

shouldShowZoomMessage({ origin }: { origin: string }): boolean {
return origin === ORIGIN.EMS && this._showZoomMessage;
}

enableZoomMessage(): void {
this._showZoomMessage = true;
}

disableZoomMessage(): void {
this._showZoomMessage = false;
}

__debugStubManifestCalls(manifestRetrieval: () => Promise<unknown>): { removeStub: () => void } {
const oldGetManifest = this._emsClient.getManifest;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ export interface IServiceSettings {
getFileLayers(): Promise<FileLayer[]>;
getUrlForRegionLayer(layer: FileLayer): Promise<string | undefined>;
setQueryParams(params: { [p: string]: string }): void;
enableZoomMessage(): void;
disableZoomMessage(): void;
getAttributesForTMSLayer(
tmsServiceConfig: TmsLayer,
isDesaturated: boolean,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/maps_legacy/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"ui": true,
"server": true,
"requiredPlugins": ["mapsEms"],
"requiredBundles": ["kibanaReact", "visDefaultEditor", "mapsEms"]
"requiredBundles": ["visDefaultEditor", "mapsEms"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,12 @@ export function BaseMapsVisualizationProvider() {
isDesaturated,
isDarkMode
);
const showZoomMessage = serviceSettings.shouldShowZoomMessage(tmsLayer);
const options = { ...tmsLayer };
delete options.id;
delete options.subdomains;
this._kibanaMap.setBaseLayer({
baseLayerType: 'tms',
options: { ...options, showZoomMessage, ...meta },
options: { ...options, ...meta },
});
}

Expand Down
23 changes: 0 additions & 23 deletions src/plugins/maps_legacy/public/map/kibana_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@
*/

import { EventEmitter } from 'events';
import { createZoomWarningMsg } from './map_messages';
import $ from 'jquery';
import { get, isEqual, escape } from 'lodash';
import { zoomToPrecision } from './zoom_to_precision';
import { i18n } from '@kbn/i18n';
import { ORIGIN } from '../../../maps_ems/common';
import { getToasts } from '../kibana_services';
import { L } from '../leaflet';

function makeFitControl(fitContainer, kibanaMap) {
Expand Down Expand Up @@ -479,22 +477,6 @@ export class KibanaMap extends EventEmitter {
this._updateLegend();
}

_addMaxZoomMessage = (layer) => {
const zoomWarningMsg = createZoomWarningMsg(
getToasts(),
this.getZoomLevel,
this.getMaxZoomLevel
);

this._leafletMap.on('zoomend', zoomWarningMsg);
this._containerNode.setAttribute('data-test-subj', 'zoomWarningEnabled');

layer.on('remove', () => {
this._leafletMap.off('zoomend', zoomWarningMsg);
this._containerNode.removeAttribute('data-test-subj');
});
};

setLegendPosition(position) {
if (this._legendPosition === position) {
if (!this._leafletLegendControl) {
Expand Down Expand Up @@ -572,11 +554,6 @@ export class KibanaMap extends EventEmitter {
});

this._leafletBaseLayer = baseLayer;
if (settings.options.showZoomMessage) {
baseLayer.on('add', () => {
this._addMaxZoomMessage(baseLayer);
});
}
this._leafletBaseLayer.addTo(this._leafletMap);
this._leafletBaseLayer.bringToBack();
if (settings.options.minZoom > this._leafletMap.getZoom()) {
Expand Down
105 changes: 0 additions & 105 deletions src/plugins/maps_legacy/public/map/map_messages.js

This file was deleted.

Loading