JavaScript API Methods
The JavaScript API exposes a number of different methods, which allow you to make temporary changes in the browser to a MarkerKit widget. You can add/remove objects and artboards, change properties, toggle fullscreen, zoom and pan, and more.
Execute a Method
The following example shows how to wait for the MarkerKit widget to load, and then use the createObject method to add a Spot object
to an artboard:
The first argument is an object, containing all props that we wish to override from the Object schema defaults, and the second parament is the ID of the artboard. For a full list of all available methods, please refer to the table below.
Methods
Objects
| Method Name | Arguments | Description |
|---|---|---|
| listObjects | artboard ID (string) | Retrieves all objects on a specific artboard. |
| getObject | object ID (string) | Retrieves an object by its ID. |
| createObject | Object (partial) , artboard ID (string) | Creates an object and adds it to an artboard. |
| updateObject | object ID (string) , Object (partial) | Updates properties of an existing object. |
| deleteObject | object ID (string) | Deletes an object by its ID. |
| getActiveObject | Retrieves the currently active object. | |
| setActiveObject | object ID (string) | Sets an object as the currently active object. |
Artboards
| Method Name | Arguments | Description |
|---|---|---|
| listArtboards | Retrieves all artboards in the MarkerKit. | |
| getArtboard | artboard ID (string) | Retrieves an artboard by its ID. |
| createArtboard | Artboard (partial) | Creates an artboard. |
| updateArtboard | artboard ID (string) , Artboard (partial) | Updates properties of an existing artboard. |
| deleteArtboard | artboard ID (string) | Deletes an artboard by its ID. |
| getActiveArtboard | Retrieves the currently active artboard. | |
| setActiveArtboard | artboard ID (string) | Sets an artboard as the currently active artboard. |
Popups
| Method Name | Arguments | Description |
|---|---|---|
| listPopups | Retrieves all popups in the MarkerKit. | |
| getPopup | popup ID (string) | Retrieves a popup by its ID. |
| createPopup | Popup (partial) | Creates a popup and associates it with an object. |
| updatePopup | popup ID (string) , Popup (partial) | Updates properties of an existing popup. |
| deletePopup | popup ID (string) | Deletes a popup by its ID. |
Other Methods
| Method Name | Arguments | Description |
|---|---|---|
| goFullscreen | Enters fullscreen mode. | |
| exitFullscreen | Exits fullscreen mode. | |
| logEvent | custom event name (string) , custom event data (object) | Logs a custom event for analytics purposes. |
| destroy | Destroys the MarkerKit instance and removes it from the DOM. |