Skip to content

Commit

Permalink
[Maps] deprecate 'map.regionmap' kibana config and 'Configured GeoJSO…
Browse files Browse the repository at this point in the history
…N' source (#103373)

* [Maps] deprecate 'map.regionmap' kibana config and 'Configured GeoJSON' source

* clean up message

* revert change to KibanaRegionmapSource.getGeoJsonWithMeta

* tslint

* doc updates

* clean up

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
nreese and kibanamachine authored Jun 28, 2021
1 parent 1965315 commit bf6be21
Show file tree
Hide file tree
Showing 15 changed files with 144 additions and 189 deletions.
1 change: 0 additions & 1 deletion docs/maps/connect-to-ems.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ To disable EMS, change your <<settings, kibana.yml>> file.

. Set `map.includeElasticMapsService` to `false` to turn off the EMS connection.
. Set `map.tilemap.url` to the URL of your tile server. This configures the default tile layer of Maps.
. (Optional) Set `map.regionmap` to the vector shapes of the administrative boundaries that you want to use.

[float]
[id=elastic-maps-server]
Expand Down
28 changes: 15 additions & 13 deletions docs/setup/settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ The time interval policy will rotate the log file every given interval of time.

| [[regionmap-ES-map]] `map.includeElasticMapsService:` {ess-icon}
| Set to `false` to disable connections to Elastic Maps Service.
When `includeElasticMapsService` is turned off, only the vector layers configured by <<regionmap-settings, `map.regionmap`>>
and the tile layer configured by <<tilemap-url, `map.tilemap.url`>> are available in <<maps, Maps>>. *Default: `true`*
When `includeElasticMapsService` is turned off, only tile layer configured by <<tilemap-url, `map.tilemap.url`>> is available in <<maps, Maps>>. *Default: `true`*

| `map.emsUrl:`
| Specifies the URL of a self hosted <<elastic-maps-server,{hosted-ems}>>
Expand All @@ -379,7 +378,8 @@ and the tile layer configured by <<tilemap-url, `map.tilemap.url`>> are availabl
requests through the {kib} server. *Default: `false`*

| [[regionmap-settings]] `map.regionmap:` {ess-icon}
| Specifies additional vector layers for
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Specifies additional vector layers for
use in <<maps, Maps>> visualizations. Each layer
object points to an external vector file that contains a geojson
FeatureCollection. The file must use the
Expand All @@ -393,7 +393,6 @@ The following example shows a valid region map configuration.
[source,text]
--
map.regionmap:
includeElasticMapsService: false
layers:
- name: "Departments of France"
url: "http://my.cors.enabled.server.org/france_departements.geojson"
Expand All @@ -409,10 +408,12 @@ map.regionmap:
|===

| [[regionmap-attribution]] `map.regionmap.layers[].attribution:` {ess-icon}
| Optional. References the originating source of the geojson file.
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Optional. References the originating source of the geojson file.

| [[regionmap-fields]] `map.regionmap.layers[].fields[]:` {ess-icon}
| Mandatory. Each layer
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Mandatory. Each layer
can contain multiple fields to indicate what properties from the geojson
features you wish to expose. The following shows how to define multiple
properties:
Expand All @@ -422,7 +423,6 @@ properties:
[source,text]
--
map.regionmap:
includeElasticMapsService: false
layers:
- name: "Departments of France"
url: "http://my.cors.enabled.server.org/france_departements.geojson"
Expand All @@ -438,24 +438,26 @@ map.regionmap:
|===

| [[regionmap-field-description]] `map.regionmap.layers[].fields[].description:` {ess-icon}
| Mandatory. The human readable text that is shown under the Options tab when
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Mandatory. The human readable text that is shown under the Options tab when
building the Region Map visualization.

| [[regionmap-field-name]] `map.regionmap.layers[].fields[].name:` {ess-icon}
| Mandatory.
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Mandatory.
This value is used to do an inner-join between the document stored in
{es} and the geojson file. For example, if the field in the geojson is
called `Location` and has city names, there must be a field in {es}
that holds the same values that {kib} can then use to lookup for the geoshape
data.

| [[regionmap-name]] `map.regionmap.layers[].name:` {ess-icon}
| Mandatory. A description of
the map being provided.
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Mandatory. A description of the map being provided.

| [[regionmap-url]] `map.regionmap.layers[].url:` {ess-icon}
| Mandatory. The location of the
geojson file as provided by a webserver.
| deprecated:[7.14.0,"In 8.0 and later, this setting will no longer be supported."]
Mandatory. The location of the geojson file as provided by a webserver.

| [[tilemap-settings]] `map.tilemap.options.attribution:` {ess-icon}
| The map attribution string.
Expand Down
5 changes: 0 additions & 5 deletions x-pack/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ export enum SCALING_TYPES {
MVT = 'MVT',
}

export enum FORMAT_TYPE {
GEOJSON = 'geojson',
TOPOJSON = 'topojson',
}

export enum MVT_FIELD_TYPE {
STRING = 'String',
NUMBER = 'Number',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import { emsBoundariesLayerWizardConfig } from '../sources/ems_file_source';
// @ts-ignore
import { emsBaseMapLayerWizardConfig } from '../sources/ems_tms_source';
// @ts-ignore
import { kibanaRegionMapLayerWizardConfig } from '../sources/kibana_regionmap_source';
// @ts-ignore
import { kibanaBasemapLayerWizardConfig } from '../sources/kibana_tilemap_source';
import { tmsLayerWizardConfig } from '../sources/xyz_tms_source';
// @ts-ignore
Expand Down Expand Up @@ -59,8 +57,6 @@ export function registerLayerWizards() {
// @ts-ignore
registerLayerWizard(emsBaseMapLayerWizardConfig);
// @ts-ignore
registerLayerWizard(kibanaRegionMapLayerWizardConfig);
// @ts-ignore
registerLayerWizard(kibanaBasemapLayerWizardConfig);
registerLayerWizard(tmsLayerWizardConfig);
// @ts-ignore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,17 @@ export class VectorLayer extends AbstractLayer implements IVectorLayer {
}

const sourceDataRequest = this.getSourceDataRequest();
const { tooltipContent, areResultsTrimmed } = this.getSource().getSourceTooltipContent(
sourceDataRequest
);
const {
tooltipContent,
areResultsTrimmed,
isDeprecated,
} = this.getSource().getSourceTooltipContent(sourceDataRequest);
return {
icon: this.getCurrentStyle().getIcon(),
icon: isDeprecated ? (
<EuiIcon type="alert" color="danger" />
) : (
this.getCurrentStyle().getIcon()
),
tooltipContent,
areResultsTrimmed,
};
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { FeatureCollection } from 'geojson';
import * as topojson from 'topojson-client';
import { GeometryCollection } from 'topojson-specification';
import fetch from 'node-fetch';

export enum FORMAT_TYPE {
GEOJSON = 'geojson',
TOPOJSON = 'topojson',
}

export async function fetchGeoJson(
fetchUrl: string,
format: FORMAT_TYPE,
featureCollectionPath: string
): Promise<FeatureCollection> {
let fetchedJson;
try {
const response = await fetch(fetchUrl);
if (!response.ok) {
throw new Error('Request failed');
}
fetchedJson = await response.json();
} catch (e) {
throw new Error(
i18n.translate('xpack.maps.util.requestFailedErrorMessage', {
defaultMessage: `Unable to fetch vector shapes from url: {fetchUrl}`,
values: { fetchUrl },
})
);
}

if (format === FORMAT_TYPE.GEOJSON) {
return fetchedJson;
}

if (format === FORMAT_TYPE.TOPOJSON) {
const features = _.get(fetchedJson, `objects.${featureCollectionPath}`) as GeometryCollection;
return topojson.feature(fetchedJson, features);
}

throw new Error(
i18n.translate('xpack.maps.util.formatErrorMessage', {
defaultMessage: `Unable to fetch vector shapes from url: {format}`,
values: { format },
})
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
* 2.0.
*/

export { kibanaRegionMapLayerWizardConfig } from './kibana_regionmap_layer_wizard';
export { KibanaRegionmapSource } from './kibana_regionmap_source';

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@

import { i18n } from '@kbn/i18n';
import { AbstractVectorSource, GeoJsonWithMeta } from '../vector_source';
import { fetchGeoJson, getKibanaRegionList } from '../../../util';
import { getRegionmapLayers } from '../../../kibana_services';
import { getDataSourceLabel } from '../../../../common/i18n_getters';
import { FIELD_ORIGIN, FORMAT_TYPE, SOURCE_TYPES } from '../../../../common/constants';
import { FIELD_ORIGIN, SOURCE_TYPES } from '../../../../common/constants';
import { KibanaRegionField } from '../../fields/kibana_region_field';
import { registerSource } from '../source_registry';
import { KibanaRegionmapSourceDescriptor } from '../../../../common/descriptor_types';
import { Adapters } from '../../../../../../../src/plugins/inspector/common/adapters';
import { IField } from '../../fields/field';
import type { LayerConfig } from '../../../../../../../src/plugins/maps_ems/public';
import { fetchGeoJson, FORMAT_TYPE } from './fetch_geojson';

export const sourceTitle = i18n.translate('xpack.maps.source.kbnRegionMapTitle', {
const sourceTitle = i18n.translate('xpack.maps.source.kbnRegionMapTitle', {
defaultMessage: 'Configured GeoJSON',
});

Expand Down Expand Up @@ -45,6 +46,7 @@ export class KibanaRegionmapSource extends AbstractVectorSource {
}

async getImmutableProperties() {
const vectorFileMeta = await this.getVectorFileMeta();
return [
{
label: getDataSourceLabel(),
Expand All @@ -56,11 +58,17 @@ export class KibanaRegionmapSource extends AbstractVectorSource {
}),
value: this._descriptor.name,
},
{
label: i18n.translate('xpack.maps.source.kbnRegionMap.vectorLayerUrlLabel', {
defaultMessage: 'Vector layer url',
}),
value: vectorFileMeta.url,
},
];
}

async getVectorFileMeta(): Promise<LayerConfig> {
const regionList: LayerConfig[] = getKibanaRegionList();
const regionList: LayerConfig[] = getRegionmapLayers();
const layerConfig: LayerConfig | undefined = regionList.find(
(regionConfig: LayerConfig) => regionConfig.name === this._descriptor.name
);
Expand Down Expand Up @@ -107,6 +115,19 @@ export class KibanaRegionmapSource extends AbstractVectorSource {
hasTooltipProperties() {
return true;
}

getSourceTooltipContent() {
return {
tooltipContent: i18n.translate('xpack.maps.source.kbnRegionMap.deprecationTooltipMessage', {
defaultMessage: `'Configured GeoJSON' layer is deprecated. 1) Use 'Upload GeoJSON' to upload '{vectorLayer}'. 2) Use Choropleth layer wizard to build a replacement layer. 3) Finally, delete this layer from your map.`,
values: {
vectorLayer: this._descriptor.name,
},
}),
areResultsTrimmed: false,
isDeprecated: true,
};
}
}

registerSource({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { DataRequest } from '../../util/data_request';
export interface SourceTooltipConfig {
tooltipContent: string | null;
areResultsTrimmed: boolean;
isDeprecated?: boolean;
}

export type GeoJsonFetchMeta = ESSearchSourceResponseMeta;
Expand Down
Loading

0 comments on commit bf6be21

Please sign in to comment.