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);