PrizmDoc v13.1 - Updated
Class: MarkupLayerCollection

Class: MarkupLayerCollection

PCCViewer. MarkupLayerCollection

(protected) new MarkupLayerCollection(viewerControl)

The MarkupLayerCollection object is used to hold and manage the markup layers as they are added, removed, shown and hidden. These actions will determine what marks and comments are displayed.

After creating a MarkupLayerCollection, PCCViewer.MarkupLayer objects may be added and removed from it. Additionally, mark references may also be added to it.

The MarkupLayerCollection object also provides an event subscription method, to get notified of other types of information. See PCCViewer.MarkupLayerCollection.EventType.

Parameters:
Name Type Description
viewerControl string

The PCCViewer.ViewerControl for the loaded document.

Example
// Get the `MarkupLayerCollection` associated with the viewerControl
var layerCollection = viewerControl.getMarkupLayerCollection()
// Get all the layers in a collection
var layers = layerCollection.getAll();
// Remove a layer from a collection
layerCollection.remove(layers[0].getId());

//register some events
layerCollection
  .on(PCCViewer.MarkupLayerCollection.EventType.MarkupLayerAdded,
      function(ev) {
          alert("Markup layer added to the collection with id = " + ev.layerId);
      })
  .on(PCCViewer.MarkupLayerCollection.EventType.MarkupLayerRemoved,
      function(ev) {
          alert("Markup layer removed from the collection with id = " + ev.layerId);
      });

Members

(static, readonly) EventType :string

A list of events that can be triggered by the PCCViewer.MarkupLayerCollection object.

Note: This enumeration is for convenience for API developers. Instead of using this enumeration, you can pass string values of the eventType (enumeration values)

Type:
  • string
Properties:
Name Type Description
MarkupLayerAdded string
MarkupLayerRemoved string
See:

(readonly) viewerControl :Object

Gets the viewer control associated with this markup layer collection.

This property is defined on all MarkupLayerCollection objects.

This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods.

Type:
  • Object
See:
Example
var viewerControl = MarkupLayerCollection.viewerControl;

(readonly) viewerControl :Object

Gets the number representing how many layers are in the collection.

This property is defined on all MarkupLayerCollection objects.

This is an ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8. For the greatest browser compatibility, use the corresponding getter and setter methods.

Type:
  • Object
See:
Example
var layerCount = MarkupLayerCollection.count;

Methods

addItem(layer) → {PCCViewer.MarkupLayerCollection}

This method is used to add a layer to the collection.

Parameters:
Name Type Description
layer PCCViewer.MarkupLayer

A markup layer object.

Returns:

The markup layer collection object on which this method was called.

Type
PCCViewer.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layer = new PCCViewer.MarkupLayer(viewerControl);
layerCollection.addItem(layer);

forEach(iterator, thisArgopt) → {PCCViewer.MarkupLayerCollection}

A method to iterate over all items in the collection. This method matches the spec for Array.prototype.forEach.

Parameters:
Name Type Attributes Description
iterator function | PCCViewer.MarkupLayerCollection~iterator

The function to execute for each item in the collection.

thisArg * <optional>

The Object to be used as this for the iterator function.

Throws:

If the iterator parameter is not a function.

Type
TypeError
Returns:

The markup layer collection Object on which this method was called.

Type
PCCViewer.MarkupLayerCollection

getAll() → {Array.<PCCViewer.MarkupLayer>}

Gets all the layers from the collection.

Returns:

An array of markup layer objects.

Type
Array.<PCCViewer.MarkupLayer>
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();

getCount() → {number}

Gets the number representing how many layers are in the collection.

Returns:

The number representing how many layers are in the collection.

Type
number
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layerCount = layerCollection.getCount();

getItem(layerId) → {PCCViewer.MarkupLayer|undefined}

Gets a specific layer from the collection.

Parameters:
Name Type Description
layerId string

A layer ID that corresponds to a layer object contained in the collection.

Returns:

A markup layer object or undefined if layerId does not correspond to a layer in the collection.

Type
PCCViewer.MarkupLayer | undefined
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();
var layer = layerCollection.getItem(layers[0].getId());

getViewerControl() → {PCCViewer.ViewerControl}

Gets the viewer control associated with this layer.

Returns:

A viewer control object.

Type
PCCViewer.ViewerControl
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var viewerControl = layerCollection.getViewerControl();

off(eventType, handler) → {PCCViewer.MarkupLayerCollection}

Unsubscribe an event handler from a specified event type.

Typically, an event is unsubscribed when you no longer want further notification of the event.

Parameters:
Name Type Description
eventType string

A string specifying the event type. See PCCViewer.MarkupLayerCollection.EventType for a list and description of all supported events.

handler PCCViewer.Event~eventHandler

A function that was attached previously to the ViewerControl.

Note: This must be the same function object previously passed to PCCViewer.MarkupLayerCollection#on. It cannot be a different object that is functionally equivalent.

See:
Returns:

The MarkupLayerCollection object on which this method was called.

Type
PCCViewer.MarkupLayerCollection

on(eventType, handler) → {PCCViewer.MarkupLayerCollection}

Subscribe an event handler to an event of a specified type.

Parameters:
Name Type Description
eventType string

A string that specifies the event type. This value is case-insensitive. See PCCViewer.MarkupLayerCollection.EventType for a list and description of all supported events.

handler PCCViewer.Event~eventHandler

A function that will be called whenever the event is triggered.

See:
Returns:

The MarkupLayerCollection object on which this method was called.

Type
PCCViewer.MarkupLayerCollection

removeAll() → {PCCViewer.MarkupLayerCollection}

This method is used to remove all layers from the collection.

Returns:

The markup layer collection object on which this method was called.

Type
PCCViewer.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
layerCollection.removeAll();

removeItem(layerId) → {PCCViewer.MarkupLayerCollection}

This method is used to remove a layer from the collection.

Parameters:
Name Type Description
layerId string

An ID of a layer in the collection.

Returns:

The markup layer collection object on which this method was called.

Type
PCCViewer.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();
layerCollection.removeItem(layers[0].getId());