---
title: "ReferenceMapStyle | 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.

# Class ReferenceMapStyle

An instance of reference style contains a list of StyleVariants ordered by relevance

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Methods[](#methods)

[addVariant](#addvariant) [getDefaultVariant](#getdefaultvariant) [getId](#getid) [getName](#getname) [getVariant](#getvariant) [getVariants](#getvariants) [hasVariant](#hasvariant)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new ReferenceMapStyle(name: string, id: string): ReferenceMapStyle[](#constructorreferencemapstyle)
    
    #### Parameters
    
    -   name: string
        
        Human-friendly name of this reference style
        
    -   id: string
        
        ID of this reference style
        
    
    #### Returns ReferenceMapStyle
    

## Methods[](#methods-1)

### addVariant[](#addvariant)

-   addVariant(v: [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)): void[](#addvariant-1)
    
    Add a variant to _this_ reference style
    
    #### Parameters
    
    -   v: [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)
    
    #### Returns void
    

### getDefaultVariant[](#getdefaultvariant)

-   getDefaultVariant(): [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)[](#getdefaultvariant-1)
    
    Get the defualt variant for this reference style
    
    #### Returns [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)
    

### getId[](#getid)

-   getId(): string[](#getid-1)
    
    Get the id of _this_ reference style
    
    #### Returns string
    

### getName[](#getname)

-   getName(): string[](#getname-1)
    
    Get the human-friendly name of this reference style
    
    #### Returns string
    

### getVariant[](#getvariant)

-   getVariant(variantType: string): [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)[](#getvariant-1)
    
    Get a given variant. If the given type of variant does not exist for this reference style, then the most relevant default variant is returned instead
    
    #### Parameters
    
    -   variantType: string
    
    #### Returns [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)
    

### getVariants[](#getvariants)

-   getVariants(): [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)\[\][](#getvariants-1)
    
    Get the list of variants for this reference style
    
    #### Returns [MapStyleVariant](https://docs.maptiler.com/sdk-js/api-reference/classes/MapStyleVariant/)\[\]
    

### hasVariant[](#hasvariant)

-   hasVariant(variantType: string): boolean[](#hasvariant-1)
    
    Check if a given variant type exists for this reference style
    
    #### Parameters
    
    -   variantType: string
    
    #### Returns boolean
