Just a random thought. What if, for each chunk, you built an image from the topmost visible node, assigning a color value, like minetestmapper, and constructing an image, on the fly, for each generated chunk. If possible, also store that generated tile string for the chunk, and use it, if available, or generate if not.
I made a map mod at one point, but the image files for the world quickly get too large for MT to handle. Even with an image size of 4096x4096, for balancing quick load times with detailed images, would require a substantial number of image tiles. If I tiled a world map at 2km intervals, (30x30) = 900 image files would need to be created. This essentially blows MT up. Lower quality images didn't really provide enough detail to be useful. Still, if you play in a small enough area, the mod might be useful.
Here's the link for my lib_sfinv_map
mod on github. Please note, you will need to use minetestmapper et.al. to generate a map image, and then place that map image into the folder. I haven't worked on or used this mod in some time, but I can improve it, if there is interest. It should be compatible with Unified Inventory, Inv Plus, and sfinv. It also provide a standalone hud, a placeable map and maptable, as well as a hand held map.