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

The **`CaretPosition`** interface represents the caret position, an indicator for the text insertion point. You can get a CaretPosition using the Document.caretPositionFromPoint() method.

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

interface CaretPosition {  
    [offset](#offset): number;  
    [offsetNode](#offsetnode): [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/);  
    [getClientRect](#getclientrect-1)(): [DOMRect](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMRect/) | null;  
}

##### Index

### Properties[](#properties)

[offset](#offset) [offsetNode](#offsetnode)

### Methods[](#methods)

[getClientRect](#getclientrect)

## Properties[](#properties-1)

### `Readonly`offset[](#offset)

offset: number

The **`offset`** property of the CaretPosition interface returns an integer representing the offset of the selection in the caret position node.

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

### `Readonly`offsetNode[](#offsetnode)

offsetNode: [Node](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.Node/)

The **`offsetNode`** property of the CaretPosition interface returns a Node containing the found node at the caret's position.

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

## Methods[](#methods-1)

### getClientRect[](#getclientrect)

-   getClientRect(): [DOMRect](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMRect/) | null[](#getclientrect-1)
    
    The **`getClientRect()`** method of the CaretPosition interface returns the client rectangle for the caret range.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/CaretPosition/getClientRect)
    
    #### Returns [DOMRect](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.DOMRect/) | null
