'Positioning SKTileMapNode in Swift Spritekit

I tried to position the Tile Map so that the bottom left of it is attached to the bottom left of the screen. Below is the code i tried to use:

func setUpSceneWithMap(map: SKTileMapNode) {
        let tileMap = map

        tileMap.setScale(1)
        tileMap.position = CGPoint(x: 0 - self.frame.size.width/2, y: 0 - self.frame.size.height/2)
                    ...
        tileMap.addChild(tileNode)

    }

Noted that I added the tile map using the GameScene.sks and not programatically. I was hoping that the position of the map should work as defined. However, when i tried to run it, the map did move, but the image that i used for my tile stayed at the same location and refused to update. Instead, it created the weird texture as follow. Please see attached image to see what happen. I am stuck at this for days and appreciate any help...



Solution 1:[1]

Add this

self.tileMap?.anchorPoint = .zero

This is the complete example:

https://github.com/Maetschl/SpriteKitExamples/blob/master/CenterTileMap/CenterTileMap/GameScene.swift

And the image:

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Maetschl