diff --git a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js index ae22f730e39f3..1ce728de919f8 100644 --- a/src/core_plugins/tile_map/public/coordinate_maps_visualization.js +++ b/src/core_plugins/tile_map/public/coordinate_maps_visualization.js @@ -1,14 +1,12 @@ import _ from 'lodash'; import { GeohashLayer } from './geohash_layer'; import { BaseMapsVisualizationProvider } from './base_maps_visualization'; -import { SearchSourceProvider } from 'ui/courier/data_source/search_source'; import { VisAggConfigProvider } from 'ui/vis/agg_config'; import './styles/_tilemap.less'; export function CoordinateMapsVisualizationProvider(Notifier, Private) { const AggConfig = Private(VisAggConfigProvider); - const SearchSource = Private(SearchSourceProvider); const BaseMapsVisualization = Private(BaseMapsVisualizationProvider); class CoordinateMapsVisualization extends BaseMapsVisualization { @@ -142,8 +140,7 @@ export function CoordinateMapsVisualizationProvider(Notifier, Private) { async getGeohashBounds() { const agg = this._getGeoHashAgg(); if (agg) { - const searchSource = new SearchSource(); - searchSource.index(this.vis.indexPattern); + const searchSource = this.vis.API.createInheritedSearchSource(this.vis.searchSource); searchSource.size(0); searchSource.aggs(function () { const geoBoundsAgg = new AggConfig(agg.vis, { diff --git a/src/ui/public/vis/vis.js b/src/ui/public/vis/vis.js index 697de1f3ce2b8..43fe40b60cee8 100644 --- a/src/ui/public/vis/vis.js +++ b/src/ui/public/vis/vis.js @@ -64,6 +64,12 @@ export function VisProvider(Private, Promise, indexPatterns, timefilter, getAppS const appState = getAppState(); brushEvent(appState)(event); } + }, + createInheritedSearchSource: (parentSearchSource) => { + if (!parentSearchSource) { + throw new Error('Unable to inherit search source, visualize saved object does not have search source.'); + } + return new SearchSource().inherits(parentSearchSource); } }; } diff --git a/src/ui/public/visualize/visualize.js b/src/ui/public/visualize/visualize.js index 136cc68947ef6..1800b019084cb 100644 --- a/src/ui/public/visualize/visualize.js +++ b/src/ui/public/visualize/visualize.js @@ -52,6 +52,7 @@ uiModules }); $scope.vis = $scope.savedObj.vis; + $scope.vis.searchSource = $scope.savedObj.searchSource; // Set the passed in uiState to the vis object. uiState reference should never be changed if (!$scope.uiState) $scope.uiState = $scope.vis.getUiState();