Instantiate a Tilemap prefab

Hello. I am making a procedurally generated map. I have created prefabs of different rooms, they are all tilemaps. Whenever I run my code, the rooms are instantiating in the right positions, but it seems to only render one block form my tilemap directly in the center. I have tried instantiating like this

rand = Random.Range(0, templates.bottomRooms.Length);
                GameObject room = templates.bottomRooms[rand];
                Instantiate(room, new Vector2(transform.position.x, transform.position.y), Quaternion.identity);

and this

rand = Random.Range(0, templates.topRooms.Length);
                Instantiate(templates.topRooms[rand], transform.position, templates.topRooms[rand].transform.rotation);

but both are giving me the same issue. I do not run into this issue when loading individual textures. However making these rooms using that method seems very tedious.

Is there a separate way to instantiate tilemaps?

Thank you.

After some troubleshooting I realized that this was occurring only because a tilemap needs to exist under a grid object. I had to set the parent to be the same as the object spawning my new rooms.

rand = Random.Range(0, templates.rightRooms.Length);
GameObject room = Instantiate(templates.rightRooms[rand], transform.position, templates.rightRooms[rand].transform.rotation);
room.transform.parent = gameObject.transform.parent;