Skip to main content

Marker

Component for Managing Markers along with creating different types of markers. Every marker is a Simple2DMarker. For every marker that needs to be added, you can use the Manager to add the marker and change its look and feel. 📕 Tutorial. 📘 API.

Extends

  • Component

Implements

  • Disposable

Properties

autoCluster

autoCluster: boolean = true

Indicates whether markers should be automatically clustered. If true, markers will be clustered based on the threshold value. Default value is true.


enabled

enabled: boolean = true

OBC.Component.enabled

Overrides

OBC.Component.enabled


list

list: Map<string, Map<string, IMarker>>

A Map containing the markers grouped by world UUID. Each world can have its own set of markers.


onDisposed

readonly onDisposed: Event<unknown>

OBC.Disposable.onDisposed

Implementation of

OBC.Disposable.onDisposed


threshold

threshold: number = 50

The distance threshold for clustering markers. Markers within this distance will be considered for clustering. Default value is 50.


uuid

static readonly uuid: "4079eb91-79b0-4ede-bcf2-15b837129236"

A unique identifier for the component. This UUID is used to register the component within the Components system.

Accessors

color

get color(): string

Getter for the color property. Returns the current color of the markers.

set color(value): void

Setter for the color property. Updates the color of all the markers to the new value.

Parameters

ParameterTypeDescription
valuestringThe new color value for the markers.

Returns

string

The current color of the markers.

Methods

cluster()

cluster(world): void

Performs clustering of markers in the given world.

Parameters

ParameterTypeDescription
worldWorldThe world where clustering will be performed.

Returns

void


create()

create(world, text, point, isStatic): undefined | string

Creates a new marker at the specified point in the world.

Parameters

ParameterTypeDefault valueDescription
worldWorldundefinedThe world where the marker will be created.
textstringundefinedThe text content of the marker.
pointVector3undefinedThe 3D position where the marker will be placed.
isStaticbooleanfalseIndicates whether the marker should be static and not clustered.

Returns

undefined | string

The unique key of the created marker.


delete()

delete(id): void

Deletes a marker with the specified ID from all worlds.

Parameters

ParameterTypeDescription
idstringThe unique identifier of the marker to be deleted.

Returns

void

Remarks

This method iterates through all the worlds and their respective markers. If a marker with the specified ID is found, it disposes of the marker's label and removes the marker from the world's marker list.


dispose()

dispose(type?): void

OBC.Disposable.dispose

Parameters

ParameterType
type?string

Returns

void

Implementation of

OBC.Disposable.dispose


getWorldMarkerList()

getWorldMarkerList(world): Map<string, IMarker>

Retrieves the list of markers associated with a specific world. If the list does not exist for the given world, it creates a new one.

Parameters

ParameterTypeDescription
worldWorldThe world for which the marker list is to be retrieved.

Returns

Map<string, IMarker>

A Map containing the markers associated with the given world.

Remarks

This method is used to manage markers per world. It ensures that each world has its own set of markers. If a marker list for the given world does not exist, it creates a new one and associates it with the world.


setupEvents()

setupEvents(world, enabled): void

Sets up event listeners for clustering markers in the given world.

Parameters

ParameterTypeDescription
worldWorldThe world where the event listeners will be set up.
enabledbooleanIndicates whether the event listeners should be enabled or disabled.

Returns

void

Remarks

This method checks if the event listeners are already set up for the given world. If the event listeners are already set up and the enabled parameter is true, the method returns without doing anything. If the world does not have camera controls, the method returns without doing anything.

The method then retrieves the event listener for the given world using the getWorldEvent method. It removes the existing event listeners for the "sleep" and "rest" events from the world's camera controls.

If the enabled parameter is true, the method adds the event listener for the "sleep" and "rest" events to the world's camera controls.