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

# Interface ScreenOrientation

The **`ScreenOrientation`** interface of the Screen Orientation API provides information about the current orientation of the document.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation)

interface ScreenOrientation {  
    [angle](#angle): number;  
    [onchange](#onchange): ((this: ScreenOrientation, ev: Event) \=> any) | null;  
    [type](#type): [OrientationType](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.OrientationType/);  
    [addEventListener](#addeventlistener-1)<[K](#addeventlistenerk) extends "change"\>(  
        type: [K](#addeventlistenerk),  
        listener: (  
            this: ScreenOrientation,  
            ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#addeventlistenerk)\],  
        ) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [addEventListener](#addeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void;  
    [dispatchEvent](#dispatchevent-1)(event: Event): boolean;  
    [lock](#lock-1)(orientation: [OrientationLockType](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.OrientationLockType/)): Promise<void\>;  
    [removeEventListener](#removeeventlistener-1)<[K](#removeeventlistenerk) extends "change"\>(  
        type: [K](#removeeventlistenerk),  
        listener: (  
            this: ScreenOrientation,  
            ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#removeeventlistenerk)\],  
        ) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [removeEventListener](#removeeventlistener-2)(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void;  
    [unlock](#unlock-1)(): void;  
}

#### Hierarchy

-   EventTarget
    -   ScreenOrientation

##### Index

### Properties[](#properties)

[angle](#angle) [onchange](#onchange) [type](#type)

### Methods[](#methods)

[addEventListener](#addeventlistener) [dispatchEvent](#dispatchevent) [lock](#lock) [removeEventListener](#removeeventlistener) [unlock](#unlock)

## Properties[](#properties-1)

### `Readonly`angle[](#angle)

angle: number

The **`angle`** read-only property of the ScreenOrientation interface returns the document's current orientation angle.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/angle)

### onchange[](#onchange)

onchange: ((this: ScreenOrientation, ev: Event) \=> any) | null

[MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/change_event)

### `Readonly`type[](#type)

type: [OrientationType](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.OrientationType/)

The **`type`** read-only property of the ScreenOrientation interface returns the document's current orientation type, one of portrait-primary, portrait-secondary, landscape-primary, or landscape-secondary.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/type)

## Methods[](#methods-1)

### addEventListener[](#addeventlistener)

-   addEventListener<[K](#addeventlistenerk) extends "change"\>(  
        type: [K](#addeventlistenerk),  
        listener: (  
            this: ScreenOrientation,  
            ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#addeventlistenerk)\],  
        ) \=> any,  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-1)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Type Parameters
    
    -   K extends "change"
    
    #### Parameters
    
    -   type: [K](#addeventlistenerk)
    -   listener: (this: ScreenOrientation, ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#addeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    
-   addEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | AddEventListenerOptions,  
    ): void[](#addeventlistener-2)
    
    The **`addEventListener()`** method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | AddEventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.addEventListener
    

### dispatchEvent[](#dispatchevent)

-   dispatchEvent(event: Event): boolean[](#dispatchevent-1)
    
    The **`dispatchEvent()`** method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent)
    
    #### Parameters
    
    -   event: Event
    
    #### Returns boolean
    
    Inherited from EventTarget.dispatchEvent
    

### lock[](#lock)

-   lock(orientation: [OrientationLockType](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.OrientationLockType/)): Promise<void\>[](#lock-1)
    
    The **`lock()`** method of the ScreenOrientation interface locks the orientation of the containing document to the specified orientation.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/lock)
    
    #### Parameters
    
    -   orientation: [OrientationLockType](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.OrientationLockType/)
    
    #### Returns Promise<void\>
    

### removeEventListener[](#removeeventlistener)

-   removeEventListener<[K](#removeeventlistenerk) extends "change"\>(  
        type: [K](#removeeventlistenerk),  
        listener: (  
            this: ScreenOrientation,  
            ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#removeeventlistenerk)\],  
        ) \=> any,  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-1)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Type Parameters
    
    -   K extends "change"
    
    #### Parameters
    
    -   type: [K](#removeeventlistenerk)
    -   listener: (this: ScreenOrientation, ev: [ScreenOrientationEventMap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ScreenOrientationEventMap/)\[[K](#removeeventlistenerk)\]) \=> any
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    
-   removeEventListener(  
        type: string,  
        listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/),  
        options?: boolean | EventListenerOptions,  
    ): void[](#removeeventlistener-2)
    
    The **`removeEventListener()`** method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener)
    
    #### Parameters
    
    -   type: string
    -   listener: [EventListenerOrEventListenerObject](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.EventListenerOrEventListenerObject/)
    -   `Optional`options: boolean | EventListenerOptions
    
    #### Returns void
    
    Overrides EventTarget.removeEventListener
    

### unlock[](#unlock)

-   unlock(): void[](#unlock-1)
    
    The **`unlock()`** method of the ScreenOrientation interface unlocks the orientation of the containing document, effectively locking it to the default screen orientation.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/ScreenOrientation/unlock)
    
    #### Returns void
