Skip to content

Commit 86bea22

Browse files
[Maps] Add 3rd party vector tile support (#62084)
Adds support for adding an external vector tile service to Maps. This is experimental functionality. To enable, add `xpack.maps.enableVectorTiles: true` to the `kibana.yml`configuration file.
1 parent eb56bfe commit 86bea22

File tree

37 files changed

+816
-118
lines changed

37 files changed

+816
-118
lines changed

src/plugins/kibana_react/public/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export * from './ui_settings';
2525
export * from './field_icon';
2626
export * from './table_list_view';
2727
export * from './split_panel';
28-
export { ValidatedDualRange } from './validated_range';
28+
export { ValidatedDualRange, Value } from './validated_range';
2929
export * from './notifications';
3030
export { Markdown, MarkdownSimple } from './markdown';
3131
export { reactToUiComponent, uiToReactComponent } from './adapters';

src/plugins/kibana_react/public/validated_range/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
* under the License.
1818
*/
1919

20-
export { ValidatedDualRange } from './validated_dual_range';
20+
export { ValidatedDualRange, Value } from './validated_dual_range';

x-pack/legacy/plugins/maps/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export function maps(kibana) {
3838
return {
3939
showMapVisualizationTypes: serverConfig.get('xpack.maps.showMapVisualizationTypes'),
4040
showMapsInspectorAdapter: serverConfig.get('xpack.maps.showMapsInspectorAdapter'),
41+
enableVectorTiles: serverConfig.get('xpack.maps.enableVectorTiles'),
4142
preserveDrawingBuffer: serverConfig.get('xpack.maps.preserveDrawingBuffer'),
4243
isEmsEnabled: mapConfig.includeElasticMapsService,
4344
emsFontLibraryUrl: mapConfig.emsFontLibraryUrl,
@@ -85,6 +86,7 @@ export function maps(kibana) {
8586
showMapVisualizationTypes: Joi.boolean().default(false),
8687
showMapsInspectorAdapter: Joi.boolean().default(false), // flag used in functional testing
8788
preserveDrawingBuffer: Joi.boolean().default(false), // flag used in functional testing
89+
enableVectorTiles: Joi.boolean().default(false), // flag used to enable/disable vector-tiles
8890
}).default();
8991
},
9092

x-pack/legacy/plugins/maps/public/connected_components/layer_addpanel/view.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export class AddLayerPanel extends Component {
6363
return;
6464
}
6565

66-
const style =
66+
const styleDescriptor =
6767
this.state.layer && this.state.layer.getCurrentStyle()
6868
? this.state.layer.getCurrentStyle().getDescriptor()
6969
: null;
7070
const layerInitProps = {
7171
...options,
72-
style: style,
72+
style: styleDescriptor,
7373
};
7474
const newLayer = source.createDefaultLayer(layerInitProps, this.props.mapColors);
7575
if (!this._isMounted) {

x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import {
1313
updateLayerMinZoom,
1414
updateLayerAlpha,
1515
} from '../../../actions/map_actions';
16+
import { MAX_ZOOM } from '../../../../../../../plugins/maps/common/constants';
1617

1718
function mapStateToProps(state = {}) {
1819
const selectedLayer = getSelectedLayer(state);
1920
return {
21+
minVisibilityZoom: selectedLayer.getMinSourceZoom(),
22+
maxVisibilityZoom: MAX_ZOOM,
2023
alpha: selectedLayer.getAlpha(),
2124
label: selectedLayer.getLabel(),
2225
layerId: selectedLayer.getId(),

x-pack/legacy/plugins/maps/public/connected_components/layer_panel/layer_settings/layer_settings.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@ import { ValidatedRange } from '../../../../../../../plugins/maps/public/compone
1313
import { i18n } from '@kbn/i18n';
1414
import { FormattedMessage } from '@kbn/i18n/react';
1515
import { ValidatedDualRange } from '../../../../../../../../src/plugins/kibana_react/public';
16-
import { MAX_ZOOM, MIN_ZOOM } from '../../../../common/constants';
17-
1816
export function LayerSettings(props) {
1917
const onLabelChange = event => {
2018
const label = event.target.value;
2119
props.updateLabel(props.layerId, label);
2220
};
2321

2422
const onZoomChange = ([min, max]) => {
25-
props.updateMinZoom(props.layerId, Math.max(MIN_ZOOM, parseInt(min, 10)));
26-
props.updateMaxZoom(props.layerId, Math.min(MAX_ZOOM, parseInt(max, 10)));
23+
props.updateMinZoom(props.layerId, Math.max(props.minVisibilityZoom, parseInt(min, 10)));
24+
props.updateMaxZoom(props.layerId, Math.min(props.maxVisibilityZoom, parseInt(max, 10)));
2725
};
2826

2927
const onAlphaChange = alpha => {
@@ -38,8 +36,8 @@ export function LayerSettings(props) {
3836
defaultMessage: 'Visibility',
3937
})}
4038
formRowDisplay="columnCompressed"
41-
min={MIN_ZOOM}
42-
max={MAX_ZOOM}
39+
min={props.minVisibilityZoom}
40+
max={props.maxVisibilityZoom}
4341
value={[props.minZoom, props.maxZoom]}
4442
showInput="inputWithPopover"
4543
showRange

x-pack/legacy/plugins/maps/public/connected_components/map/mb/view.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ import {
1414
} from './utils';
1515
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
1616
import { getGlyphUrl, isRetina } from '../../../../../../../plugins/maps/public/meta';
17-
import { DECIMAL_DEGREES_PRECISION, ZOOM_PRECISION } from '../../../../common/constants';
17+
import {
18+
DECIMAL_DEGREES_PRECISION,
19+
MAX_ZOOM,
20+
MIN_ZOOM,
21+
ZOOM_PRECISION,
22+
} from '../../../../common/constants';
1823
import mapboxgl from 'mapbox-gl/dist/mapbox-gl-csp';
1924
import mbWorkerUrl from '!!file-loader!mapbox-gl/dist/mapbox-gl-csp-worker';
2025
import mbRtlPlugin from '!!file-loader!@mapbox/mapbox-gl-rtl-text/mapbox-gl-rtl-text.min.js';
@@ -132,6 +137,8 @@ export class MBMapContainer extends React.Component {
132137
scrollZoom: this.props.scrollZoom,
133138
preserveDrawingBuffer: getInjectedVarFunc()('preserveDrawingBuffer', false),
134139
interactive: !this.props.disableInteractive,
140+
minZoom: MIN_ZOOM,
141+
maxZoom: MAX_ZOOM,
135142
};
136143
const initialView = _.get(this.props.goto, 'center');
137144
if (initialView) {

x-pack/legacy/plugins/maps/public/plugin.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
8-
import '../../../../plugins/maps/public/layers/layer_wizard_registry';
9-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
10-
import '../../../../plugins/maps/public/layers/sources/source_registry';
11-
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
12-
import '../../../../plugins/maps/public/layers/load_layer_wizards';
13-
147
import { Plugin, CoreStart, CoreSetup } from 'src/core/public';
158
// @ts-ignore
169
import { Start as InspectorStartContract } from 'src/plugins/inspector/public';

x-pack/legacy/plugins/maps/public/selectors/map_selectors.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { BlendedVectorLayer } from '../../../../../plugins/maps/public/layers/bl
1919
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
2020
import { getTimeFilter } from '../../../../../plugins/maps/public/kibana_services';
2121
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
22+
import { TiledVectorLayer } from '../../../../../plugins/maps/public/layers/tiled_vector_layer';
23+
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
2224
import { getInspectorAdapters } from '../../../../../plugins/maps/public/reducers/non_serializable_instances';
2325
import {
2426
copyPersistentState,
@@ -51,6 +53,8 @@ function createLayerInstance(layerDescriptor, inspectorAdapters) {
5153
return new HeatmapLayer({ layerDescriptor, source });
5254
case BlendedVectorLayer.type:
5355
return new BlendedVectorLayer({ layerDescriptor, source });
56+
case TiledVectorLayer.type:
57+
return new TiledVectorLayer({ layerDescriptor, source });
5458
default:
5559
throw new Error(`Unrecognized layerType ${layerDescriptor.type}`);
5660
}

x-pack/legacy/plugins/maps/public/selectors/map_selectors.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
jest.mock('../../../../../plugins/maps/public/layers/vector_layer', () => {});
8+
jest.mock('../../../../../plugins/maps/public/layers/tiled_vector_layer', () => {});
89
jest.mock('../../../../../plugins/maps/public/layers/blended_vector_layer', () => {});
910
jest.mock('../../../../../plugins/maps/public/layers/heatmap_layer', () => {});
1011
jest.mock('../../../../../plugins/maps/public/layers/vector_tile_layer', () => {});

0 commit comments

Comments
 (0)