'Overall layout for visible components
@param components: the components as dict
{name: (label, widget, id, hidden)}
@param map icon: the map icon
@param formstyle: the formstyle (falls back to CRUD formstyle)'

def _layout(self, components, map_icon=None, formstyle=None, inline=False):

    if (formstyle is None):
        formstyle = current.response.s3.crud.formstyle
    row = formstyle('test', 'test', 'test', 'test')
    if isinstance(row, tuple):
        tuple_rows = True
        table_style = (inline and (row[0].tag == 'tr'))
    else:
        tuple_rows = False
        table_style = False
    selectors = (DIV() if (not table_style) else TABLE())
    for name in ('L0', 'L1', 'L2', 'L3', 'L4', 'L5'):
        if (name in components):
            (label, widget, input_id, hidden) = components[name]
            formrow = formstyle(('%s__row' % input_id), label, widget, '', hidden=hidden)
            if tuple_rows:
                selectors.append(formrow[0])
                selectors.append(formrow[1])
            else:
                selectors.append(formrow)
    inputs = (TAG['']() if (not table_style) else TABLE())
    for name in ('address', 'postcode', 'lat', 'lon', 'latlon_toggle'):
        if (name in components):
            (label, widget, input_id, hidden) = components[name]
            formrow = formstyle(('%s__row' % input_id), label, widget, '', hidden=hidden)
            if tuple_rows:
                inputs.append(formrow[0])
                inputs.append(formrow[1])
            else:
                inputs.append(formrow)
    output = TAG[''](selectors, inputs)
    if map_icon:
        output.append(map_icon)
    return output
