Reference·JavaScript · @bimworks/viewercommonJavaScript

AnnotationLayer

Class in @bimworks/viewercommon.

API catalogue · @bimworks/viewercommon · Class

TypeScript#
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#

TypeScript#
constructor()

inheritedFrom: EventTarget.constructor

Type parameters#

Name Constraint Description
D ``

expandMode#

TypeScript#
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#

TypeScript#
readonly group: string

keyMode#

TypeScript#
readonly keyMode: "qid" | "globalId"

What identifies its rows, fixed when it is made: the key option, else the template's default

ready#

TypeScript#
readonly ready: Promise<void>

Settles when the query's rows are in; rejects when the query fails

removed#

TypeScript#
readonly removed: boolean

size#

TypeScript#
readonly size: number

How many rows are shown

template#

TypeScript#
readonly template: AnnotationTemplate<D>

visible#

TypeScript#
readonly visible: boolean

addEventListener#

TypeScript#
addEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | AddEventListenerOptions): void

The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.

MDN Reference

inheritedFrom: EventTarget.addEventListener

Parameters#

Name Type Description
type string
callback EventListenerOrEventListenerObject | null
options boolean | AddEventListenerOptions

collapse#

TypeScript#
collapse(key?: string | Qid): void

Closes a row's card, or all of the layer's cards

Parameters#

Name Type Description
key string | Qid

dispatchEvent#

TypeScript#
dispatchEvent(event: Event): boolean

The 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().

MDN Reference

inheritedFrom: EventTarget.dispatchEvent

Parameters#

Name Type Description
event Event

expand#

TypeScript#
expand(key: string | Qid, options?: { pin?: boolean }): boolean

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#

TypeScript#
get(key: string | Qid): AnnotationRow<D> | undefined

Parameters#

Name Type Description
key string | Qid

option#

TypeScript#
option(name: keyof AnnotationLayerOptions<D>): unknown

A layer option, or the template's default for it

Parameters#

Name Type Description
name keyof AnnotationLayerOptions<D>

refresh#

TypeScript#
refresh(): Promise<void>

Runs the query again, dropping a run in flight, and diffs the result by key

remove#

TypeScript#
remove(): void

Removes the layer from every viewer

removeEventListener#

TypeScript#
removeEventListener(type: string, callback: EventListenerOrEventListenerObject | null, options?: boolean | EventListenerOptions): void

The 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.

MDN Reference

inheritedFrom: EventTarget.removeEventListener

Parameters#

Name Type Description
type string
callback EventListenerOrEventListenerObject | null
options boolean | EventListenerOptions

rows#

TypeScript#
rows(): IterableIterator<AnnotationRow<D>>

setFilter#

TypeScript#
setFilter(filter: (row: AnnotationRow<D>) => boolean | null): void

Parameters#

Name Type Description
filter (row: AnnotationRow<D>) => boolean | null

setOptions#

TypeScript#
setOptions(options: Partial<Pick<AnnotationLayerOptions<D>, "occlusion" | "clustering" | "limit" | "scaleByDistance" | "maxDistanceMm" | "visibility" | "anchor" | "align" | "expand" | "dotBeyondMm" | "onClick" | "onAction">>): void

Parameters#

Name Type Description
options Partial<Pick<AnnotationLayerOptions<D>, "occlusion" | "clustering" | "limit" | "scaleByDistance" | "maxDistanceMm" | "visibility" | "anchor" | "align" | "expand" | "dotBeyondMm" | "onClick" | "onAction">>

setQuery#

TypeScript#
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#

TypeScript#
setRows(rows: Iterable<AnnotationRow<Partial<D>>>): void

Replaces the application's rows, diffed by key: unchanged rows keep their DOM

Parameters#

Name Type Description
rows Iterable<AnnotationRow<Partial<D>>>

setTemplate#

TypeScript#
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#

TypeScript#
setVisible(visible: boolean): void

Parameters#

Name Type Description
visible boolean

update#

TypeScript#
update(key: string | Qid, patch: Partial<D>): void

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#

TypeScript#
updateMany(patches: Iterable<[key: string | Qid, patch: Partial<D>]>): void

Parameters#

Name Type Description
patches Iterable<[key: string | Qid, patch: Partial<D>]>