If I have two identical maps, I can save the coordinates and move to the same point from where I teleported, but to another map.
But the fact is that the maps are different and I can teleport into a wall or furniture.
Therefore, I need to split into regions and appear approximately in the area from where I teleported. Let's say I can switch to another map and I have the number of the region to jump to.
But for that, I need the coordinates of the map. How can i get location info (Tile ID) from region ID????
The way I'd handle this problem would be to simplify it.
I would identify a few designated "safe" teleport destinations on each map.
Then, when the player tries to teleport, use a formula to determine which designation on the target map is most suitable based on the current player coordinates.
You can save each map's target teleport locations to variables (or set them as self-variables in an event on that map using a self-variable plugin to keep things cleaner) , and get the player current coordinates using a script call.
Then, you can just have some conditions that, depending on whether the X and Y are within specific ranges, teleports the player to the appropriate pre-set location on the other map.
If you are willing to move the player's destination to avoid walls and obstacles in the first place, I can't imagine it would be that big of a change to make them arrive in a more limited range of target locations in general. You can set as many target possibilities as you want, depending on the map size.
Of course, if you have like 200 maps this might not be worth the work. It would depend on your game.