Changing Tiles on a map at runtime, using other maps templates

I’m developing an isometric game on libgdx, based on TileMapEditor. Pretty good editor I must say. I want to change maps at runtime, deleting or inserting new tiles. I’ve got minimaps saved aside and loaded at boot, that share the same layers and tilesets of the gamemap, and I want to use the minimaps as templates of structures preloaded, for placing group of tiles on the gamemap at runtime. The problem seems to be this: when I try to set a new tile in an empty layer cell of the gamemap, by reading the tile from the minimap, the gamemap is actually updated (the correct tile is placed and seen on the gamemap), but the tile id seems not to correspond to the proper parent tileset: or it is not existing, or it belongs to another tileset. So when I save the map (via json map of tiles id) and load it back, I got problems..

Question 1: different tmx maps with same tilesets generate different tile ids, depending on some runtime logics?

Question 2: how can I read the local tileset ID of a Tile? May be it would be easier to retrieve the gamemap equivalent tile id upon placing it from another minimap sharing the same tilesets, just by finding the same tile local id on the same tileset of gamemap at runtime..

Question3: what am I missing?

Thanks..

What you seem to be missing is this page in the docs: Global Tile IDs — Tiled 1.11.0 documentation

Global tile IDs may differ for each map (typically based on tileset order, but there’s no guarantee - Tiled may do it one way, but another software writing TMX/TMJ may do it another way), but the map contains all the info you need to map a global ID to a tileset and the tile’s local ID within that tileset.
GIDs are just a storage convenience for the file formats, you should not be working with them at runtime beyond loading the map data. Instead, you could store runtime tile references as e.g. {tileset reference, local ID}.

Thanks a lot. But I’m afraid on java there is no tiledMapTileSet.getFirst_gid() method available.. will work it in another way I guess.. But you have been very useful.. Seems that Libgdx wrapper (java) does not expose many usefull api.

Since you’re using a library that handles the parsing for you, you probably already have a Tile or some similar thing you should be using instead of trying to work with GIDs yourself, so you might be overthinking the issue or overlooking more high-level methods available to you for dealing with tiles across maps.