Class: AnnotationItemFactory

OSDPaperjsAnnotation.AnnotationItemFactory()

Represents a factory for creating and managing AnnotationItem instances.

Constructor

new AnnotationItemFactory()

Source:

Methods

(static) getConstructor(geoJSON) → {function|undefined}

This static method retrieves a constructor from the registered constructors based on the provided GeoJSON feature. It matches the geometry type and subtype to determine the appropriate constructor.
Parameters:
Name Type Description
geoJSON Object The GeoJSON feature object.
Source:
Returns:
A constructor function or undefined if no matching constructor is found.
Type
function | undefined

(static) itemFromAnnotationItem(item) → {paper.Item|undefined}

This static method creates a new paper.Item instance based on an existing AnnotationItem. It retrieves the underlying AnnotationItem and converts it to a GeoJSON feature. Then, it creates a new paper.Item using the `itemFromGeoJSON` method of the AnnotationItemFactory.
Parameters:
Name Type Description
item paper.Item The paper.Item instance associated with an AnnotationItem.
Source:
Returns:
A paper.Item instance created from the AnnotationItem, or undefined if the item is not associated with an AnnotationItem.
Type
paper.Item | undefined

(static) itemFromGeoJSON(geoJSON) → {paper.Item|undefined}

This static method creates an AnnotationItem instance from a GeoJSON feature. It retrieves a matching constructor based on the GeoJSON geometry type and subtype, and then creates an AnnotationItem instance using that constructor.
Parameters:
Name Type Description
geoJSON Object The GeoJSON feature object.
Source:
Returns:
A paper.Item instance or undefined if no matching constructor is found.
Type
paper.Item | undefined

(static) register(ctor)

This static method registers a constructor to the AnnotationItemFactory. It checks whether the constructor implements the required static accessor supportsGeoJSONType.
Parameters:
Name Type Description
ctor function The constructor function for creating AnnotationItem instances.
Source:
Throws:
Throws an error if the provided constructor does not implement the necessary API.
Type
string