API / geotoolkit / widgets / overlays / AnnotationOverlay / AnnotationOverlay
overlays.AnnotationOverlay.AnnotationOverlay
Creates default implementation of the widget annotation overlay
Example
import {AnnotationOverlay, Events as Overlay} from '@int/geotoolkit/widgets/overlays/AnnotationOverlay';
import {log} from '@int/geotoolkit/base';
const overlay = new AnnotationOverlay(widget, {
'annotationcontainer': 'geotoolkit-plot-host'
})
.on(OverlayEvents.AnnotationAdded, (event, sender, eventArgs) => {
const annotation = eventArgs.getAnnotation();
log('Annotation ' + annotation.getText() + ' added');
log('Total annotations is: ' + sender.getAnnotations().toArray().length);
})
.on(OverlayEvents.AnnotationRemoved, (event, sender, eventArgs) => {
const annotation = eventArgs.getAnnotation();
log('Annotation ' + annotation.getText() + ' removed');
log('Total annotations is: ' + sender.getAnnotations().toArray().length);
});| Name | Type |
|---|---|
W | extends BaseWidget = BaseWidget |
↳
AnnotationOverlay
Methods
Constructors
• new AnnotationOverlay<W>(widget, options?)
Creates annotation overlay
Throws
if 'overlay' is not provided or 'overlays' layer is not exist in the parent widget
| Name | Type |
|---|---|
W | extends BaseWidget<W> = BaseWidget |
| Name | Type | Description |
|---|---|---|
widget | W | parent widget to add overlay |
Optional options | Options | options |
AbstractOverlay<W&gt;.constructor
Methods
▸ addAnnotation(annotation): IAnnotation
Add annotation
Throws
Error if annotation is null
| Name | Type | Description |
|---|---|---|
annotation | IAnnotation | Annotation | annotation object |
▸ clearAnnotations(silent?): AnnotationOverlay<W>
Clear annotations
| Name | Type | Description |
|---|---|---|
Optional silent | boolean | silent mode, default is true |
▸ dispose(): void
Disposes this node, once disposes a node should not be used anymore.
Clear all listeners, and disconnect styles to avoid memory leaks.
Also aggressively 'cleanup' this node by setting some of its members to null.
void
▸ editAnnotation(annotation): AnnotationOverlay<W>
Edit annotation, by default it starts embedded TextArea editor
| Name | Type | Description |
|---|---|---|
annotation | IAnnotation | annotation to edit |
this
▸ getActiveAnnotation(): IAnnotation
Return active annotation
annotation
▸ getAnnotations(filter?): Iterator<IAnnotation>
Return iterator by child nodes
| Name | Type | Description |
|---|---|---|
Optional filter | (item: IAnnotation) => boolean | a filter function. Returns all nodes if null |
▸ getClassName(): string
string
▸ getCss(): CssStyle
Return CSS style
▸ getEditorContainer(): HTMLElement
Returns HTML container with inline editors
HTMLElement
HTMLElement
▸ getEnabled(): boolean
Return enabled state
boolean
enabled state
▸ Protected getModel(): Group<Node>
▸ getOptions(): OptionsType
Return options
object
▸ getVisible(): boolean
Return visibility state
boolean
visible state
▸ getWidget(): W
Returns widget
W
widget
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
AbstractOverlay.hasEventListener
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ notify<E>(type, source, args?): AnnotationOverlay<W>
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | AnnotationOverlay<W> | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): AnnotationOverlay<W>
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: AnnotationOverlay<W>, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): AnnotationOverlay<W>
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: AnnotationOverlay<W>, args: EventMap[E]) => void | to be called |
this
▸ Protected onStateChanged(state): AnnotationOverlay<W>
| Name | Type | Description |
|---|---|---|
state | "Visible" | "Enabled" | overlay state |
this
AbstractOverlay.onStateChanged
▸ Protected onUpdateGeometry(): void
void
▸ removeAnnotation(annotation): AnnotationOverlay<W>
Remove annotation
| Name | Type | Description |
|---|---|---|
annotation | IAnnotation | annotation to be removed |
this
▸ scrollToAnnotation(annotation): AnnotationOverlay<W>
Scroll to annotation
| Name | Type | Description |
|---|---|---|
annotation | IAnnotation | annotation |
▸ setActiveAnnotation(annotation): AnnotationOverlay<W>
Set active annotation
| Name | Type | Description |
|---|---|---|
annotation | IAnnotation | annotation |
▸ setCss(style, merge?): AnnotationOverlay<W>
Sets CSS style. This style will be applied for all inserted elements
| Name | Type | Description |
|---|---|---|
style | Type | CSS style to be applied to inserted elements |
Optional merge | boolean | merge flag |
this
▸ setEnabled(enabled): AnnotationOverlay<W>
Set enabled state
| Name | Type | Description |
|---|---|---|
enabled | boolean | enable or disable tools |
this
▸ setOptions(options): AnnotationOverlay<W>
Set options
| Name | Type | Description |
|---|---|---|
options | OptionsType | options |
▸ setOrientation(orientation): AnnotationOverlay<W>
Set orientation
| Name | Type | Description |
|---|---|---|
orientation | Orientation | overlay orientation |
this
▸ setSilent(bool): AnnotationOverlay<W>
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ setVisible(visible): AnnotationOverlay<W>
Set visibility state
| Name | Type | Description |
|---|---|---|
visible | boolean | visibility of overlay |
this
▸ Static getClassName(): string
string
▸ Static getGeometry(geometryName): Function
Return known geometry
| Name | Type | Description |
|---|---|---|
geometryName | string | geometry name |
Function
extension geometry extension
▸ Static registerGeometry(geometryName, extension): void
Register geometry extension
| Name | Type | Description |
|---|---|---|
geometryName | string | geometry name |
extension | Function | geometry extension |
void