---
title: addMarker
slug: viewer-2d/methods/addMarker
docTags: 
createdAt: 2024-02-21T14:33:53.989Z
---

Adds a marker to the specified location.

## Example

::codepen{url="https://codepen.io/Catenda/embed/PorJMNb"}

## Usage

```javascript
const marker = {
  x: 0,
  y: 0
};

const markerId = viewer2d.addMarker(marker);
```

## Parameters

### marker

Marker to add.

| **Type** | **Required** |
| -------- | ------------ |
| Object   | Yes          |

**Properties**

| **Name**    | **Type**                             | **Required** | **Description**                                    |
| ----------- | ------------------------------------ | ------------ | -------------------------------------------------- |
| `clickable` | Boolean                              | No           | Marker is clickable                                |
| `color`     | String                               | No           | Color of the marker, defaults to red               |
| `data`      | Object                               | No           | Optional data to associate with the marker         |
| `draggable` | Boolean                              | No           | Marker position will change when dragged           |
| `icon`      | [Icon](docId\:ErSDQ9zOshf8pcPFlvJPH) | No           | Replace the default marker icon                    |
| `id`        | String                               | No           | Id of the marker                                   |
| `text`      | String                               | No           | Optional text label displayed alongside the marker |
| `x`         | Number                               | Yes          | X coordinate of the marker in pixels               |
| `y`         | Number                               | Yes          | Y coordinate of the marker in pixels               |

## Return Value

Id of the marker.

| **Type** |
| -------- |
| String   |

