# Get and remove a map tile by click

**URL:** <https://phaser.discourse.group/t/get-and-remove-a-map-tile-by-click/5184>\
**Category:** Phaser 3\
**Created:** [February 14, 2020, 1:52pm UTC](https://phaser.discourse.group/t/get-and-remove-a-map-tile-by-click/5184 "2020-02-14T13:52:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmb272](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jmb272](https://phaser.discourse.group/u/jmb272)\
**Post date:** [February 14, 2020, 1:52pm UTC](https://phaser.discourse.group/t/get-and-remove-a-map-tile-by-click/5184/1 "2020-02-14T13:52:16Z")

</div>

Hi all, I’m trying to get to grips with tile maps. I want to be able to create a map layer, then be able to get each tile and remove it by clicking on it.

I’ve created a simple map with one layer in Tiled Editor. I’ve then loaded the map into Phaser.

I was thinking somewhere along the lines of this, but I can’t get it to work.

this.input.on(‘pointerup’, function(pointer) {  
var tile = map.getTileAt(pointer.x, pointer.y);  
console.log(tile);  
}, this);

But I keep getting “null” in the console.

Any help would be appreciated thanks.

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [February 14, 2020, 5:12pm UTC](https://phaser.discourse.group/t/get-and-remove-a-map-tile-by-click/5184/2 "2020-02-14T17:12:06Z")

</div>

Try

```javascript
this.input.on('pointerup', function (pointer) {
  var tile = map.getTileAtWorldXY(pointer.worldX, pointer.worldY);

  console.log(pointer.worldX, pointer.worldY, tile);
}, this);

```

---

<div class="post-metadata">

**Author:** ![jmb272](https://avatars.discourse-cdn.com/v4/letter/j/e8c25b/32.png) [@jmb272](https://phaser.discourse.group/u/jmb272)\
**Post date:** [February 14, 2020, 5:47pm UTC](https://phaser.discourse.group/t/get-and-remove-a-map-tile-by-click/5184/3 "2020-02-14T17:47:11Z")

</div>

It works. Thanks a lot samme.
