From 2bb672a7de0617ac09a849810bc4b0ebc7e9ddce Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Tue, 31 Jan 2023 18:31:54 -0500 Subject: [PATCH] [v9.4.x] Geomap: Ensure options work while in table view (#62635) Geomap: Ensure options work while in table view (#62632) (cherry picked from commit cf6952a963ba42cacef2ab246249b619fec61936) Co-authored-by: Drew Slobodnjak <60050885+drew08t@users.noreply.github.com> --- public/app/plugins/panel/geomap/GeomapPanel.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/public/app/plugins/panel/geomap/GeomapPanel.tsx b/public/app/plugins/panel/geomap/GeomapPanel.tsx index f4070048c01..cc7ce494331 100644 --- a/public/app/plugins/panel/geomap/GeomapPanel.tsx +++ b/public/app/plugins/panel/geomap/GeomapPanel.tsx @@ -82,6 +82,8 @@ export class GeomapPanel extends Component { for (const lyr of this.layers) { lyr.handler.dispose?.(); } + // Ensure map is disposed + this.map?.dispose(); } shouldComponentUpdate(nextProps: Props) { @@ -183,15 +185,15 @@ export class GeomapPanel extends Component { } initMapRef = async (div: HTMLDivElement) => { + if (!div) { + // Do not initialize new map or dispose old map + return; + } this.mapDiv = div; if (this.map) { this.map.dispose(); } - if (!div) { - this.map = undefined; - return; - } const { options } = this.props; const map = getNewOpenLayersMap(this, options, div);