---
title: "addPolygon | 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 addPolygon

-   addPolygon(  
        map: [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/),  
        options: [PolygonLayerOptions](https://docs.maptiler.com/sdk-js/api-reference/types/PolygonLayerOptions/),  
    ): {  
        polygonLayerId: string;  
        polygonOutlineLayerId: string;  
        polygonSourceId: string;  
    }[](#addpolygon)
    
    Add a polygon with styling options.
    
    #### Parameters
    
    -   map: [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/)
    -   options: [PolygonLayerOptions](https://docs.maptiler.com/sdk-js/api-reference/types/PolygonLayerOptions/)
    
    #### Returns {  
        polygonLayerId: string;  
        polygonOutlineLayerId: string;  
        polygonSourceId: string;  
    }
    
    -   ##### polygonLayerId: string
        
        ID of the fill layer
        
    -   ##### polygonOutlineLayerId: string
        
        ID of the outline layer (will be `""` if no outline)
        
    -   ##### polygonSourceId: string
        
        ID of the source that contains the data
