---
title: "groupByLayout | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Function groupByLayout

-   groupByLayout(  
        layers: [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/)\[\],  
        cachedKeys?: [Record](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Record/)<string, string\>,  
    ): [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/)\[\]\[\][](#groupbylayout)
    
    Groups layers by their layout-affecting properties. These are the properties that were formerly used by explicit `ref` mechanism for layers: 'type', 'source', 'source-layer', 'minzoom', 'maxzoom', 'filter', and 'layout'.
    
    The input is not modified. The output layers are references to the input layers.
    
    #### Parameters
    
    -   layers: [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/)\[\]
        
        an array of [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/).
        
    -   `Optional`cachedKeys: [Record](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Record/)<string, string\>
        
        an object to keep already calculated keys.
        
    
    #### Returns [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/)\[\]\[\]
    
    an array of arrays of [LayerSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/LayerSpecification/) objects, where each inner array contains layers that share the same layout-affecting properties.
