Skip to content

Arrows

Arrows Draw and edit arrows

Constructors

constructor

new Arrows(ogma, options?): Arrows

Parameters

NameType
ogmaOgma<any, any>
optionsPick<Partial<ControllerOptions>, "arrowHandleSize" | "maxArrowHeight" | "minArrowHeight">

Returns

Arrows

Properties

editor

Protected editor: Overlay

elements

Protected elements: Arrow[]

hoveredId

Protected hoveredId: Id = NONE

isDragging

Protected isDragging: boolean

layer

Protected layer: SVGLayer

ogma

Protected ogma: Ogma<any, any>

ogmaOptions

Protected ogmaOptions: Options$a

selectedId

Protected selectedId: Id = NONE

shouldDetect

Protected shouldDetect: boolean

showeditorOnHover

Protected showeditorOnHover: boolean

prefixed

Static prefixed: string | boolean

Methods

add

add(options): Arrow

Parameters

NameTypeDescription
optionsArrowParams for the annotation (merged with default)

Returns

Arrow

the added annotation

Method

add

addListener

addListener<T>(event, fn, context?): this

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
fn(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void
context?any

Returns

this

cancelDrawing

cancelDrawing(): void

Returns

void

destroy

destroy(): void

Returns

void

detect

detect(point, margin?): undefined | Arrow

Parameters

NameTypeDefault value
pointPointundefined
marginnumber0

Returns

undefined | Arrow

disableDetection

disableDetection(): void

Returns

void

Method

disableDetection Disables the hover behaviour, used by controller to avoid hovering arrows while dragging texts and vice versa

disableDragging

disableDragging(): void

Returns

void

Method

disableDragging Prevents Ogma from dragging elements or moving the view while dragging an annotation

draw

draw(svg): void

Parameters

NameType
svgSVGSVGElement

Returns

void

emit

emit<T>(event, ...args): boolean

Calls each of the listeners registered for a given event.

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
...argsArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]

Returns

boolean

enableDetection

enableDetection(): void

Returns

void

eventNames

eventNames(): keyof Events<Arrow>[]

Return an array listing the events for which the emitter has registered listeners.

Returns

keyof Events<Arrow>[]

getById

getById(id): Arrow

Parameters

NameType
idId

Returns

Arrow

getDefaultOptions

getDefaultOptions(): Arrow

Returns

Arrow

getElements

getElements(): Arrow[]

Returns

Arrow[]

getSelectedFeature

getSelectedFeature(): null | Arrow

Returns

null | Arrow

hover

hover(id): void

Parameters

NameType
idId

Returns

void

listenerCount

listenerCount(event): number

Return the number of listeners listening to a given event.

Parameters

NameType
eventkeyof Events<Arrow>

Returns

number

listeners

listeners<T>(event): (...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void[]

Return the listeners registered for a given event.

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT

Returns

(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void[]

off

off<T>(event, fn?, context?, once?): this

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
fn?(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void
context?any
once?boolean

Returns

this

on

on<T>(event, fn, context?): this

Add a listener for a given event.

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
fn(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void
context?any

Returns

this

onHandleMouseDown

onHandleMouseDown(evt): void

Parameters

NameType
evtMouseEvent

Returns

void

onMouseMove

onMouseMove(evt): void

Parameters

NameType
evtMouseEvent

Returns

void

onMouseUp

onMouseUp(): void

Returns

void

once

once<T>(event, fn, context?): this

Add a one-time listener for a given event.

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
fn(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void
context?any

Returns

this

refreshDrawing

refreshDrawing(): void

Returns

void

refreshEditor

refreshEditor(): void

Returns

void

refreshLayer

refreshLayer(): void

Returns

void

remove

remove(id): void

Parameters

NameTypeDescription
idIdId of the annotation to remove Removes annotation with the given id

Returns

void

Method

remove

removeAllListeners

removeAllListeners(event?): this

Remove all listeners, or those of the specified event.

Parameters

NameType
event?keyof Events<Arrow>

Returns

this

removeListener

removeListener<T>(event, fn?, context?, once?): this

Remove the listeners of a given event.

Type parameters

NameType
Textends keyof Events<Arrow>

Parameters

NameType
eventT
fn?(...args: ArgumentMap<Events<Arrow>>[Extract<T, keyof Events<Arrow>>]) => void
context?any
once?boolean

Returns

this

restoreDragging

restoreDragging(): void

Returns

void

Method

restoreDragging restore ogma options as they were before we start dragging an annotation

scale

scale(annotation, scale, ox, oy): void

Parameters

NameType
annotationArrow
scalenumber
oxnumber
oynumber

Returns

void

select

select(id): void

Parameters

NameTypeDescription
idIdid of the element to select Select element, show editor, disable Ogma dragging and fire event

Returns

void

Method

select

startDragging

startDragging(arrow, x, y): void

Parameters

NameType
arrowArrow
xnumber
ynumber

Returns

void

startDrawing

startDrawing(x, y, arrow?): void

Start drawing a new arrow, it will also be added as a new annotation

Parameters

NameType
xnumber
ynumber
arrowArrow

Returns

void

unhover

unhover(): Arrows

Returns

Arrows

unselect

unselect(): Arrows

Returns

Arrows

update

update(id, element): void

Parameters

NameTypeDescription
idIdId of the annotation to update
elementPartial<Arrow>params of the annotation

Returns

void

Method

update Updates an annotation (position, color etc)

updateAnnotation

updateAnnotation(target, element): void

Parameters

NameType
targetArrow
elementPartial<Arrow>

Returns

void

updateGeometry

updateGeometry(annotation, geometry): void

Parameters

NameType
annotationArrow
geometryPartial<LineString>

Returns

void

updateStyle

updateStyle(annotation, style): void

Parameters

NameType
annotationArrow
stylePartial<undefined | ArrowStyles>

Returns

void