# MonoGame.Extended.Tiled: Get layers for Vector2 location without iterating over all tiles? Extended

I am trying to get the layers (or better, a special object layer) which contains a Vector2 location from a TiledMap, I know I could iterate over those, but I do not want to. How would I do that?

Thanks!

Have you tried the GetLayer method on the TiledMap?

Depending on your use case, you can get the object layer specifically by using either use the generic method:

var objectLayer = map.GetLayer<TiledMapObjectLayer>("layerName");


Or you can cast it you the object layer yourself:

var objectLayer = map.GetLayer("layerName") as TiledMapObjectLayer;


In either case it will return null if the layer doesn't exist or is of the wrong type.