AnnotationLayer
Class in @bimworks/viewercommon.
API catalogue · @bimworks/viewercommon · Class
class AnnotationLayer<D = Record<string, unknown>>A set of annotations drawn by one template. Events: "loaded" (the query's rows are in), "error" (detail.error), "action" (detail: {action, row, event}), "expand" and "collapse" (detail: {row, pinned}, a card opened or closed)
Type parameters#
| Name | Constraint | Description |
|---|---|---|
D |
`` |
Inheritance and interfaces#
EventTarget
Members#
| Member | Kind | Description |
|---|---|---|
| constructor | Method | inheritedFrom: EventTarget.constructor |
| expandMode | Property | When the cards show: the expand option, "none" for a layer shown only on hover, the template's default, or "hover" for an expandable template |
| group | Property | |
| keyMode | Property | What identifies its rows, fixed when it is made: the key option, else the template's default |
| ready | Property | Settles when the query's rows are in; rejects when the query fails |
| removed | Property | |
| size | Property | How many rows are shown |
| template | Property | |
| visible | Property | |
| addEventListener | Method | The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the targ… |
| collapse | Method | Closes a row's card, or all of the layer's cards |
| dispatchEvent | Method | The dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate or… |
| expand | Method | Opens a row's card in every viewer, pinned unless {pin: false}; false without such a row or an expandable template |
| get | Method | |
| option | Method | A layer option, or the template's default for it |
| refresh | Method | Runs the query again, dropping a run in flight, and diffs the result by key |
| remove | Method | Removes the layer from every viewer |
| removeEventListener | Method | The removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from … |
| rows | Method | |
| setFilter | Method | |
| setOptions | Method | |
| setQuery | Method | |
| setRows | Method | Replaces the application's rows, diffed by key: unchanged rows keep their DOM |
| setTemplate | Method | Another template for the same rows; the query runs again when its fields differ |
| setVisible | Method | |
| update | Method | Merges a patch into a row's data; updates within one task reach the viewers once, and only shown rows re-render |
| updateMany | Method |
constructor#
constructor()inheritedFrom: EventTarget.constructor
Type parameters#
| Name | Constraint | Description |
|---|---|---|
D |
`` |
expandMode#
readonly expandMode: "none" | "click" | "hover"When the cards show: the expand option, "none" for a layer shown only on hover, the template's default, or "hover" for an expandable template
group#
readonly group: stringkeyMode#
readonly keyMode: "qid" | "globalId"What identifies its rows, fixed when it is made: the key option, else the template's default
ready#
readonly ready: Promise<void>Settles when the query's rows are in; rejects when the query fails
removed#
readonly removed: booleansize#
readonly size: numberHow many rows are shown
template#
readonly template: AnnotationTemplate<D>visible#
readonly visible: booleanaddEventListener#
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): voidThe addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.
inheritedFrom: EventTarget.addEventListener
Parameters#
| Name | Type | Description |
|---|---|---|
type |
string |
|
callback |
EventListenerOrEventListenerObject | null |
|
options |
boolean | AddEventListenerOptions |
collapse#
Closes a row's card, or all of the layer's cards
Parameters#
| Name | Type | Description |
|---|---|---|
key |
string | Qid |
dispatchEvent#
dispatchEvent(event: Event): booleanThe dispatchEvent() method of the EventTarget sends an Event to the object, (synchronously) invoking the affected event listeners in the appropriate order. The normal event processing rules (including the capturing and optional bubbling phase) also apply to events dispatched manually with dispatchEvent().
inheritedFrom: EventTarget.dispatchEvent
Parameters#
| Name | Type | Description |
|---|---|---|
event |
Event |
expand#
Opens a row's card in every viewer, pinned unless {pin: false}; false without such a row or an expandable template
Parameters#
| Name | Type | Description |
|---|---|---|
key |
string | Qid |
|
options |
{ pin?: boolean } |
get#
get(key: string | Qid): AnnotationRow<D> | undefinedParameters#
| Name | Type | Description |
|---|---|---|
key |
string | Qid |
option#
option(name: keyof AnnotationLayerOptions<D>): unknownA layer option, or the template's default for it
Parameters#
| Name | Type | Description |
|---|---|---|
name |
keyof AnnotationLayerOptions<D> |
refresh#
refresh(): Promise<void>Runs the query again, dropping a run in flight, and diffs the result by key
remove#
remove(): voidRemoves the layer from every viewer
removeEventListener#
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): voidThe removeEventListener() method of the EventTarget interface removes an event listener previously registered with EventTarget.addEventListener() from the target. The event listener to be removed is identified using a combination of the event type, the event listener function itself, and various optional options that may affect the matching process; see Matching event listeners for removal.
inheritedFrom: EventTarget.removeEventListener
Parameters#
| Name | Type | Description |
|---|---|---|
type |
string |
|
callback |
EventListenerOrEventListenerObject | null |
|
options |
boolean | EventListenerOptions |
rows#
rows(): IterableIterator<AnnotationRow<D>>setFilter#
setFilter(filter: (row: AnnotationRow<D>) => boolean | null): voidParameters#
| Name | Type | Description |
|---|---|---|
filter |
(row: AnnotationRow<D>) => boolean | null |
setOptions#
setOptions(options: Partial<Pick<AnnotationLayerOptions<D>, "occlusion" | "clustering" | "limit" | "scaleByDistance" | "maxDistanceMm" | "visibility" | "anchor" | "align" | "expand" | "dotBeyondMm" | "onClick" | "onAction">>): voidParameters#
| Name | Type | Description |
|---|---|---|
options |
Partial<Pick<AnnotationLayerOptions<D>, "occlusion" | "clustering" | "limit" | "scaleByDistance" | "maxDistanceMm" | "visibility" | "anchor" | "align" | "expand" | "dotBeyondMm" | "onClick" | "onAction">> |
setQuery#
setQuery(query: string | { get?: Record<string, string>; models?: (string)[]; parameters?: Record<string, unknown>; where?: string } | null | undefined): Promise<void>Parameters#
| Name | Type | Description |
|---|---|---|
query |
string | { get?: Record<string, string>; models?: (string)[]; parameters?: Record<string, unknown>; where?: string } | null | undefined |
setRows#
setRows(rows: Iterable<AnnotationRow<Partial<D>>>): voidReplaces the application's rows, diffed by key: unchanged rows keep their DOM
Parameters#
| Name | Type | Description |
|---|---|---|
rows |
Iterable<AnnotationRow<Partial<D>>> |
setTemplate#
setTemplate(template: string | AnnotationTemplate<D>): Promise<void>Another template for the same rows; the query runs again when its fields differ
Parameters#
| Name | Type | Description |
|---|---|---|
template |
string | AnnotationTemplate<D> |
setVisible#
setVisible(visible: boolean): voidParameters#
| Name | Type | Description |
|---|---|---|
visible |
boolean |
update#
Merges a patch into a row's data; updates within one task reach the viewers once, and only shown rows re-render
Parameters#
| Name | Type | Description |
|---|---|---|
key |
string | Qid |
|
patch |
Partial<D> |
updateMany#
Parameters#
| Name | Type | Description |
|---|---|---|
patches |
Iterable<[key: string | Qid, patch: Partial<D>]> |