How to get to javascript Leaflet Map object from everywhere?

I want to add a Heatmap Layer to a Leaflet map, while my app is built with dash_leaflet . I plan to do this using JavaScript functions because in dash_leaflet there is no heatmap wrapper. First, I need to obtain my map object, similar to how const gridAPI = await dash_ag_grid.getApiAsync("grid_id"); is used, but for a Leaflet map. Although I know that I can access the map object through event handlers (for example, see this guide on custom event handlers), I would prefer to do this outside of event handler functions. After obtaining the map object, I intend to add a heatmap as demonstrated here.

Any ideas?