ImageGear .NET v24.12 - Updated
IPCC.MarkupLayerCollection
API Reference > ViewerControl API > IPCC.MarkupLayerCollection

Class: MarkupLayerCollection

(protected) IPCC.MarkupLayerCollection(viewerControl)

(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`, IPCC.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 IPCC.MarkupLayerCollection.EventType.
Parameters:
Name Type Description
viewerControl string The IPCC.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(IPCC.MarkupLayerCollection.EventType.MarkupLayerAdded,
      function(ev) {
          alert("Markup layer added to the collection with id = " + ev.layerId);
      })
  .on(IPCC.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 IPCC.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) count :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;

(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;

Methods

addItem(layer) → {IPCC.MarkupLayerCollection}

This method is used to add a layer to the collection.
Parameters:
Name Type Description
layer IPCC.MarkupLayer A markup layer object.
Returns:
The markup layer collection object on which this method was called.
Type
IPCC.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layer = new IPCC.MarkupLayer(viewerControl);
layerCollection.addItem(layer);

forEach(iterator, thisArgopt) → {IPCC.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 | IPCC.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
IPCC.MarkupLayerCollection

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

Gets all the layers from the collection.
Returns:
An array of markup layer objects.
Type
Array.<IPCC.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) → {IPCC.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
IPCC.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() → {IPCC.ViewerControl}

Gets the viewer control associated with this layer.
Returns:
A viewer control object.
Type
IPCC.ViewerControl
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var viewerControl = layerCollection.getViewerControl();

off(eventType) → {IPCC.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 IPCC.MarkupLayerCollection.EventType for a list and description of all supported events.
`IPCC.Event~eventHandler` handler A function that was attached previously to the `ViewerControl`. **Note:** This must be the same function object previously passed to IPCC.MarkupLayerCollection#on. It cannot be a different object that is functionally equivalent.
See:
Returns:
The `MarkupLayerCollection` object on which this method was called.
Type
IPCC.MarkupLayerCollection

on(eventType) → {IPCC.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 IPCC.MarkupLayerCollection.EventType for a list and description of all supported events.
`IPCC.Event~eventHandler` handler A function that will be called whenever the event is triggered.
See:
Returns:
The `MarkupLayerCollection` object on which this method was called.
Type
IPCC.MarkupLayerCollection

removeAll() → {IPCC.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
IPCC.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
layerCollection.removeAll();

removeItem(layerId) → {IPCC.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
IPCC.MarkupLayerCollection
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();
layerCollection.removeItem(layers[0].getId());