You can iterate through layer types in a map in one of several ways.
for layer in map.<iterator name>() do
-- Do something to layer
end
map.tileLayers()
: Iterates through all tile layers in the map.map.objectLayers()
: Iterates through all object layers in the map.map.imageLayers()
: Iterates through all image layers in the map.