diff --git a/src/core_plugins/tile_map/public/maps_visualization.js b/src/core_plugins/tile_map/public/maps_visualization.js index 3b20084fa483d1..0d709c9e32a6ae 100644 --- a/src/core_plugins/tile_map/public/maps_visualization.js +++ b/src/core_plugins/tile_map/public/maps_visualization.js @@ -20,8 +20,6 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, co this.vis = vis; this.$el = $(element); this._$container = this.$el; - - this._geohashLayer = null; this._kibanaMap = null; this._kibanaMapReady = this._makeKibanaMap(); @@ -29,7 +27,6 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, co this._dataDirty = true; this._paramsDirty = true; this._currentParams = null; - this._updateParams(); } destroy() { @@ -41,21 +38,22 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, co async render(esResponse) { return new Promise((resolve) => { - if (esResponse && typeof esResponse.geohashGridAgg === 'undefined') { - this._updateParams(); - return resolve(); - } + this._updateParams().then(() => { + if (esResponse && typeof esResponse.geohashGridAgg === 'undefined') { + return resolve(); + } - //todo: do render complete! - this._dataDirty = true; - this._kibanaMapReady.then(() => { - this._chartData = esResponse; - this._geohashGeoJson = this._chartData.geoJson; - this._recreateGeohashLayer(); - this._kibanaMap.useUiStateFromVisualization(this.vis); - this._kibanaMap.resize(); - this._dataDirty = false; - this._doRenderComplete(resolve); + this._dataDirty = true; + + this._kibanaMapReady.then(() => { + this._chartData = esResponse; + this._geohashGeoJson = this._chartData.geoJson; + this._recreateGeohashLayer(); + this._kibanaMap.useUiStateFromVisualization(this.vis); + this._kibanaMap.resize(); + this._dataDirty = false; + this._doRenderComplete(resolve); + }); }); }); } @@ -169,7 +167,7 @@ export function MapsVisualizationProvider(Private, serviceSettings, Notifier, co return; } - this._currentParams = mapParams; + this._currentParams = _.cloneDeep(mapParams); const { minZoom, maxZoom } = this._getMinMaxZoom(); if (mapParams.wms.enabled) { diff --git a/src/ui/public/visualize/visualization.js b/src/ui/public/visualize/visualization.js index 54e0410e7488e7..29d6107e0c0aba 100644 --- a/src/ui/public/visualize/visualization.js +++ b/src/ui/public/visualize/visualization.js @@ -129,6 +129,12 @@ uiModules visualization.destroy(); }); + if (!$scope.vis.visualizeScope) { + $scope.$watch('visData', () => { + $scope.$emit('render'); + }); + } + resizeChecker.on('resize', resizeFunction); function jQueryGetter(selector) {