(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.
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);
});
Parameters:
Name | Type | Description |
---|---|---|
viewerControl |
string |
The PCCViewer.ViewerControl for the loaded document. |
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 | Description |
---|---|
MarkupLayerAdded : string |
|
MarkupLayerRemoved : string |
(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.
Example
var layerCount = MarkupLayerCollection.count;
Type:
- Object
(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.
Example
var viewerControl = MarkupLayerCollection.viewerControl;
Type:
- Object
Methods
addItem(layer) → {PCCViewer.MarkupLayerCollection}
This method is used to add a layer to the collection.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layer = new PCCViewer.MarkupLayer(viewerControl);
layerCollection.addItem(layer);
Parameters:
Name | Type | Description |
---|---|---|
layer |
PCCViewer.MarkupLayer |
A markup layer object. |
Returns:
The markup layer collection object on which this method was called.
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 |
Throws:
-
If the
iterator
parameter is not a function.- Type
- TypeError
Returns:
The markup layer collection Object on which this method was called.
getAll() → {Array.<PCCViewer.MarkupLayer>}
Gets all the layers from the collection.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();
Returns:
An array of markup layer objects.
- Type
- Array.<PCCViewer.MarkupLayer>
getCount() → {number}
Gets the number representing how many layers are in the collection.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layerCount = layerCollection.getCount();
Returns:
The number representing how many layers are in the collection.
- Type
- number
getItem(layerId) → {PCCViewer.MarkupLayer|undefined}
Gets a specific layer from the collection.
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());
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
getViewerControl() → {PCCViewer.ViewerControl}
Gets the viewer control associated with this layer.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var viewerControl = layerCollection.getViewerControl();
Returns:
A viewer control object.
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 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:
-
- PCCViewer.MarkupLayerCollection#on
- PCCViewer.ViewerControl#off for more details on unsubscribing event handlers.
Returns:
The MarkupLayerCollection
object on which this method was called.
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:
-
- PCCViewer.MarkupLayerCollection#off
- PCCViewer.ViewerControl#on for more details on event subscription.
Returns:
The MarkupLayerCollection
object on which this method was called.
removeAll() → {PCCViewer.MarkupLayerCollection}
This method is used to remove all layers from the collection.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
layerCollection.removeAll();
Returns:
The markup layer collection object on which this method was called.
removeItem(layerId) → {PCCViewer.MarkupLayerCollection}
This method is used to remove a layer from the collection.
Example
var layerCollection = viewerControl.getMarkupLayerCollection(); // Get the markup layer collection associated with the viewerControl
var layers = layerCollection.getAll();
layerCollection.removeItem(layers[0].getId());
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.