Sometimes, when in the early exploratory phases of a software project and you get in the weeds a bit, a good strategy can be to scrap it and start again with a simpler version. I did that.
I made a new project, that just had a Node2D, with a TileMap and a Camera2D. One interesting thing was that the TileMap had its location with the upper left corner at the center of the screen. See Image 1 below. I hadn't seen that before, but I probably didn't do something correctly, The TileMap was unaltered other than a script attached, and the tiles created programmatically. For now, I corrected it by calculating an offset and setting the TileMap's position so that its center was at the screen center. Feel free to let me know if there's a better method.
To the Camera2D script, I added the C# version of some camera zoom code I found in my research. Zoom worked perfectly, no moving around as before, it stayed centered. See Image 2.
Finally, I had some other code for dragging with the mouse. I reproduced that in the TileMap script. It sort of worked. The map would follow the mouse but it lagged badly, so you'd have to drag it several times. Trying to multiple the speed made everything jerky. So I scrapped that and just thought about what I wanted,
I wanted the TileMap to go where the mouse is. So I changed the code to shift the TileMap position to the current mouse position. That wasn't quite it, because again the TileMap position was its upper corner. So again I had to calculate an offset based on the position of the initial mouse "grab" on the TileMap, and add that offset to the current mouse position. That worked nearly perfectly. Further zoom in or out would stay centered where it was. See Image 3.


