Class: MarkerComponent
component.MarkerComponent
classdesc
Component for showing and editing 3D marker objects.
The add
method is used for adding new markers or replacing
markers already in the set.
If a marker already in the set has the same id as one of the markers added, the old marker will be removed and the added marker will take its place.
It is not possible to update markers in the set by updating any properties directly on the marker object. Markers need to be replaced by re-adding them for updates to geographic position or configuration to be reflected.
Markers added to the marker component can be either interactive
or non-interactive. Different marker types define their behavior.
Markers with interaction support can be configured with options
to respond to dragging inside the viewer and be detected when
retrieving markers from pixel points with the getMarkerIdAt
method.
To retrive and use the marker component
example
var viewer = new Viewer({ component: { marker: true }, ... });
var markerComponent = viewer.getComponent("marker");
#
HierarchyComponent
<MarkerConfiguration
>↳
MarkerComponent
#
Events#
on• on(type
, handler
): void
Fired when a marker drag interaction ends.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('markerdragend', function() { console.log("A markerdragend event has occurred.");});
#
ParametersName | Type |
---|---|
type | "markerdragend" |
handler | (event : ComponentMarkerEvent ) => void |
#
Returnsvoid
#
Overrides#
Defined incomponent/marker/MarkerComponent.ts:272
• on(type
, handler
): void
Fired when a marker drag interaction starts.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('markerdragstart', function() { console.log("A markerdragstart event has occurred.");});
#
ParametersName | Type |
---|---|
type | "markerdragstart" |
handler | (event : ComponentMarkerEvent ) => void |
#
Returnsvoid
#
Defined incomponent/marker/MarkerComponent.ts:291
• on(type
, handler
): void
Fired when the position of a marker is changed.
example
// Initialize the viewervar viewer = new Viewer({ // viewer options });var component = viewer.getComponent('<component-name>');// Set an event listenercomponent.on('markerposition', function() { console.log("A markerposition event has occurred.");});
#
ParametersName | Type |
---|---|
type | "markerposition" |
handler | (event : ComponentMarkerEvent ) => void |
#
Returnsvoid
#
Defined incomponent/marker/MarkerComponent.ts:310
#
Properties#
componentNameâ–ª Static
componentName: ComponentName
= "marker"
#
Overrides#
Defined incomponent/marker/MarkerComponent.ts:82
#
Accessors#
activated• get
activated(): boolean
Get activated.
#
Returnsboolean
Value indicating if the component is currently active.
#
Defined in#
defaultConfiguration• get
defaultConfiguration(): TConfiguration
Get default configuration.
#
ReturnsTConfiguration
Default configuration for component.
#
Defined in#
name• get
name(): string
Get name.
description
The name of the component. Used when interacting with the
component through the Viewer's API.
#
Returnsstring
#
Defined in#
Methods#
addâ–¸ add(markers
): void
Add markers to the marker set or replace markers in the marker set.
description
If a marker already in the set has the same
id as one of the markers added, the old marker will be removed
the added marker will take its place.
Any marker inside the visible bounding bbox will be initialized and placed in the viewer.
example
markerComponent.add([marker1, marker2]);
#
ParametersName | Type | Description |
---|---|---|
markers | Marker [] | Markers to add. |
#
Returnsvoid
#
Defined incomponent/marker/MarkerComponent.ts:124
#
configureâ–¸ configure(configuration
): void
Configure the component.
#
ParametersName | Type | Description |
---|---|---|
configuration | MarkerConfiguration | Component configuration. |
#
Returnsvoid
#
Inherited from#
Defined in#
fireâ–¸ fire(type
, event
): void
#
ParametersName | Type |
---|---|
type | "markerdragend" | "markerdragstart" | "markerposition" |
event | ComponentMarkerEvent |
#
Returnsvoid
#
Overrides#
Defined in../doc/component/marker/MarkerComponent.ts:128
#
getâ–¸ get(markerId
): Marker
Returns the marker in the marker set with the specified id, or undefined if the id matches no marker.
example
var marker = markerComponent.get("markerId");
#
ParametersName | Type | Description |
---|---|---|
markerId | string | Id of the marker. |
#
Returns#
Defined incomponent/marker/MarkerComponent.ts:159
#
getAllâ–¸ getAll(): Marker
[]
Returns an array of all markers.
example
var markers = markerComponent.getAll();
#
ReturnsMarker
[]
#
Defined incomponent/marker/MarkerComponent.ts:171
#
getMarkerIdAtâ–¸ getMarkerIdAt(pixelPoint
): Promise
<string
>
Returns the id of the interactive marker closest to the current camera position at the specified point.
description
Notice that the pixelPoint argument requires x, y
coordinates from pixel space.
With this function, you can use the coordinates provided by mouse events to get information out of the marker component.
If no interactive geometry of an interactive marker exist at the pixel
point, null
will be returned.
example
markerComponent.getMarkerIdAt([100, 100]) .then((markerId) => { console.log(markerId); });
#
ParametersName | Type | Description |
---|---|---|
pixelPoint | number [] | Pixel coordinates on the viewer element. |
#
ReturnsPromise
<string
>
Id of the interactive marker closest to the camera. If no
interactive marker exist at the pixel point, null
will be returned.
#
Defined incomponent/marker/MarkerComponent.ts:198
#
hasâ–¸ has(markerId
): boolean
Check if a marker exist in the marker set.
example
var markerExists = markerComponent.has("markerId");
#
ParametersName | Type | Description |
---|---|---|
markerId | string | Id of the marker. |
#
Returnsboolean
#
Defined incomponent/marker/MarkerComponent.ts:234
#
offâ–¸ off(type
, handler
): void
Unsubscribe from an event by its name.
#
ParametersName | Type |
---|---|
type | "markerdragend" | "markerdragstart" | "markerposition" |
handler | (event : ComponentMarkerEvent ) => void |
#
Returnsvoid
#
Overrides#
Defined in../doc/component/marker/MarkerComponent.ts:238
#
removeâ–¸ remove(markerIds
): void
Remove markers with the specified ids from the marker set.
example
markerComponent.remove(["id-1", "id-2"]);
#
ParametersName | Type | Description |
---|---|---|
markerIds | string [] | Ids for markers to remove. |
#
Returnsvoid
#
Defined incomponent/marker/MarkerComponent.ts:331
#
removeAllâ–¸ removeAll(): void
Remove all markers from the marker set.
example
markerComponent.removeAll();
#
Returnsvoid