---
title: "MapStyleVariant | Client js | Api client"
description: "Documentation for MapTiler Client"
---

> 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 MapStyleVariant

An instance of MapStyleVariant contains information about a style to use that belong to a reference style

-   Defined in [mapstyle.ts:49](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L49)

##### Index

### Constructors

[constructor](#constructor)

### Properties

[deprecated](#deprecated) [deprecationMessage?](#deprecationmessage)

### Methods

[getDescription](#getdescription) [getExpandedStyleURL](#getexpandedstyleurl) [getFullName](#getfullname) [getId](#getid) [getImageURL](#getimageurl) [getName](#getname) [getReferenceStyle](#getreferencestyle) [getType](#gettype) [getVariant](#getvariant) [getVariants](#getvariants) [hasVariant](#hasvariant) [warnIfDeprecated](#warnifdeprecated)

## Constructors

### constructor[](#constructor)

-   new MapStyleVariant(  
        name: string,  
        variantType: string,  
        id: string,  
        referenceStyle: [ReferenceMapStyle](https://docs.maptiler.com/client-js/api/classes/index.ReferenceMapStyle/),  
        description: string,  
        imageURL: string,  
        deprecated?: boolean,  
        deprecationMessage?: string,  
    ): MapStyleVariant[](#constructormapstylevariant)
    
    #### Parameters
    
    -   name: string
        
        Human-friendly name
        
    -   variantType: string
        
        Variant name the variant is addressed to from its reference style: `MapStyle.REFERNCE_STYLE_NAME.VARIANT_TYPE`
        
    -   id: string
        
        MapTiler Cloud id
        
    -   referenceStyle: [ReferenceMapStyle](https://docs.maptiler.com/client-js/api/classes/index.ReferenceMapStyle/)
        
        Reference map style, used to retrieve sibling variants
        
    -   description: string
        
        Human-friendly description
        
    -   imageURL: string
        
        URL to an image describing the style variant
        
    -   deprecated: boolean = false
        
        Whether this variant is deprecated or not
        
    -   `Optional`deprecationMessage: string
        
        Message to display when the variant is deprecated
        
    
    #### Returns MapStyleVariant
    
    -   Defined in [mapstyle.ts:50](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L50)
    

## Properties

### deprecated[](#deprecated)

deprecated: boolean = false

Whether this variant is deprecated or not

-   Defined in [mapstyle.ts:84](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L84)

### `Optional`deprecationMessage[](#deprecationmessage)

deprecationMessage?: string

Message to display when the variant is deprecated

-   Defined in [mapstyle.ts:89](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L89)

## Methods

### getDescription[](#getdescription)

-   getDescription(): string[](#getdescription-1)
    
    Get the human-friendly description
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:123](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L123)
    

### getExpandedStyleURL[](#getexpandedstyleurl)

-   getExpandedStyleURL(): string[](#getexpandedstyleurl-1)
    
    Get the style as usable by MapLibre, a string (URL) or a plain style description (StyleSpecification)
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:183](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L183)
    

### getFullName[](#getfullname)

-   getFullName(): string[](#getfullname-1)
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:100](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L100)
    

### getId[](#getid)

-   getId(): string[](#getid-1)
    
    Get the MapTiler Cloud id
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:116](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L116)
    

### getImageURL[](#getimageurl)

-   getImageURL(): string[](#getimageurl-1)
    
    Get the image URL that represent _this_ variant
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:175](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L175)
    

### getName[](#getname)

-   getName(): string[](#getname-1)
    
    Get the human-friendly name
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:96](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L96)
    

### getReferenceStyle[](#getreferencestyle)

-   getReferenceStyle(): [ReferenceMapStyle](https://docs.maptiler.com/client-js/api/classes/index.ReferenceMapStyle/)[](#getreferencestyle-1)
    
    Get the reference style this variant belongs to
    
    #### Returns [ReferenceMapStyle](https://docs.maptiler.com/client-js/api/classes/index.ReferenceMapStyle/)
    
    -   Defined in [mapstyle.ts:131](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L131)
    

### getType[](#gettype)

-   getType(): string[](#gettype-1)
    
    Get the variant type (eg. "DEFAULT", "DARK", "PASTEL", etc.)
    
    #### Returns string
    
    -   Defined in [mapstyle.ts:108](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L108)
    

### getVariant[](#getvariant)

-   getVariant(variantType: string): MapStyleVariant[](#getvariant-1)
    
    Retrieve the variant of a given type. If not found, will return the "DEFAULT" variant. (eg. _this_ "DARK" variant does not have any "PASTEL" variant, then the "DEFAULT" is returned)
    
    #### Parameters
    
    -   variantType: string
    
    #### Returns MapStyleVariant
    
    -   Defined in [mapstyle.ts:151](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L151)
    

### getVariants[](#getvariants)

-   getVariants(): MapStyleVariant\[\][](#getvariants-1)
    
    Get all the variants for _this_ variants, except _this_ current one
    
    #### Returns MapStyleVariant\[\]
    
    -   Defined in [mapstyle.ts:161](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L161)
    

### hasVariant[](#hasvariant)

-   hasVariant(variantType: string): boolean[](#hasvariant-1)
    
    Check if a variant of a given type exists for _this_ variants (eg. if this is a "DARK", then we can check if there is a "LIGHT" variant of it)
    
    #### Parameters
    
    -   variantType: string
    
    #### Returns boolean
    
    -   Defined in [mapstyle.ts:141](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L141)
    

### warnIfDeprecated[](#warnifdeprecated)

-   warnIfDeprecated(variant?: MapStyleVariant): MapStyleVariant[](#warnifdeprecated-1)
    
    #### Parameters
    
    -   variant: MapStyleVariant = ...
    
    #### Returns MapStyleVariant
    
    -   Defined in [mapstyle.ts:187](https://github.com/maptiler/maptiler-client-js/blob/f88659ae276c959a754e4c0f3b5c2aae1f483caa/src/mapstyle.ts#L187)
