# Class: MeasurementManager

## Core. MeasurementManager

A manager class that controls measurement of annotations and distance create tools.

#### new MeasurementManager()

### Extends

- Core.EventHandler

### Members

#### <static> Events

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `SCALE_UPDATED` | string | Core.MeasurementManager.scaleUpdated

### Methods

#### addEventListener(type, fn [, options])

  Add a handler to the given event name

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string | number |  | The name of the event to listen to
  `fn` | function |  | The handler to be called when the event is triggered
  `options` | object | <optional> | Optional options object for addEventListener ###### Properties
  Name | Type | Description
  --- | --- | ---
  `once` | boolean | If true then the handler will be called only once

  Inherited From:
    - Core.EventHandler#addEventListener

  ##### Returns:

  Returns the object that 'addEventListener' is being called on
  Type
    object

  ##### Example

      myObject.addEventListener('eventName', (eventParameter1, eventParameter2) => {
        ...
      });

#### createAndApplyScale(options)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `options` | object | The options for the scale to be created ###### Properties
  Name | Type | Description
  --- | --- | ---
  `scale` | Core.Scale | The scale object which contains the page scale, world scale and precision
  `applyTo` | Array.<(Core.Annotations.Annotation|Core.Tools.Tool)> | The measurement annotations and tools that the scale should be applied to

#### deleteScale(scale)

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `scale` | Core.Scale | The scale object that should be deleted

#### disableAnnotationAndToolStyleSyncing()

  Disable the automatic updating of annotation styles even if the corresponding measurement tool's styles are updated.

  ##### Example

      WebViewer(...)
       .then(function(instance) {
        let measurementManager = instance.Core.documentViewer.getMeasurementManager();
        measurementManager.disableAnnotationAndToolStyleSyncing()
      });

#### enableAnnotationAndToolStyleSyncing()

  Enable annotation's styles to be updated when the corresponding measurement tool's styles are updated.

  ##### Example

      WebViewer(...)
       .then(function(instance) {
        let measurementManager = instance.Core.documentViewer.getMeasurementManager();
        measurementManager.enableAnnotationAndToolStyleSyncing()
      });

#### getScales()

  ##### Returns:

  Returns an object with the keys as scale strings and the values as an array of annotations and tools that use the scale
  Type
    Object.<string, Array.<(Core.Annotations.Annotation|Core.Tools.Tool)>>

#### isAnnotationAndToolStyleSyncingEnabled()

  Return true if automatic updating of annotation styles when corresponding measurement tool's styles are updated, otherwise return false.

  ##### Returns:

  Type
    boolean

  ##### Example

      WebViewer(...)
       .then(function(instance) {
        let measurementManager = instance.Core.documentViewer.getMeasurementManager();
        measurementManager.isAnnotationAndToolStyleSyncingEnabled()
      });

#### off( [type] [, fn])

  Remove a handler of the given event name

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string | number | <optional> | The name of the event to remove the handler of. If type is undefined, all the handlers of the object will be removed
  `fn` | function | <optional> | The handler associated with this event to be removed. If fn is undefined, all the handlers of the given event name will be removed

  Inherited From:
    - Core.EventHandler#off
  Deprecated:
    - Since version 8.0. Use removeEventListener instead.

  ##### Returns:

  Returns the object that 'off' is being called on
  Type
    object

  ##### Example

      myObject.off();
      myObject.off('eventName');
      myObject.off('eventName', fn);

#### on(type, fn)

  Add a handler to the given event name

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `type` | string | number | The name of the event to listen to
  `fn` | function | The handler to be called when the event is triggered

  Inherited From:
    - Core.EventHandler#on
  Deprecated:
    - Since version 8.0. Use addEventListener instead.

  ##### Returns:

  Returns the object that 'on' is being called on
  Type
    object

  ##### Example

      myObject.on('eventName', (eventParameter1, eventParameter2) => {
        ...
      });

#### one(type, fn)

  Same as 'on' except the handler will be called only once

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `type` | string | number | The name of the event to listen to
  `fn` | function | The handler to be called when the event is triggered

  Inherited From:
    - Core.EventHandler#one
  Deprecated:
    - Since version 8.0. Use addEventListener with {'once': true} as options instead.

  ##### Returns:

  Returns the object that 'one' is being called on
  Type
    object

  ##### Example

      myObject.one('eventName', (eventParameter1, eventParameter2) => {
       ...
      });

#### removeEventListener( [type] [, fn])

  Remove a handler of the given event name

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string | number | <optional> | The name of the event to remove the handler of. If type is undefined, all the handlers of the object will be removed
  `fn` | function | <optional> | The handler associated with this event to be removed. If fn is undefined, all the handlers of the given event name will be removed

  Inherited From:
    - Core.EventHandler#removeEventListener
  Deprecated:
    - for version 9.0. Use [removeEventListener] with fn specified

  ##### Returns:

  Returns the object that 'removeEventListener' is being called on
  Type
    object

  ##### Example

      myObject.removeEventListener();
      myObject.removeEventListener('eventName');
      myObject.removeEventListener('eventName', fn);

#### replaceScale(oldScale, newScale)

  For all annotations and tools that currently use the old scale, this scale will be replaced with the new scale.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `oldScale` | Core.Scale | The old scale which is selected
  `newScale` | Core.Scale | The new scale used to replace the old scale.

  ##### Returns:

  Returns a list of annotations or measurement tools related to the newly created scale
  Type
    Array.<(Core.Annotations.Annotation|Core.Tools.Tool)>

#### replaceScales(oldScales, newScale)

  For all annotations and tools that currently use the old scales, these scales will be replaced with the new scale.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `oldScales` | Array.<Core.Scale> | The array of old scales which are selected
  `newScale` | Core.Scale | The new scale used to replace the old scales.

  ##### Returns:

  Returns a list of annotations or measurement tools related to the newly created scale
  Type
    Array.<(Core.Annotations.Annotation|Core.Tools.Tool)>

#### trigger(type [, data])

  Calls the handlers of the event name with given data

  ##### Parameters:

  Name | Type | Argument | Description
  --- | --- | --- | ---
  `type` | string | number |  | event name of which the handlers will be called.
  `data` | * | <optional> | data that will be passed to the handlers. If data is an array, it will be spread and then passed to the handlers

  Inherited From:
    - Core.EventHandler#trigger

  ##### Returns:

  Returns the object that 'trigger' is being called on
  Type
    object

  ##### Example

      myObject.trigger('eventName');
      myObject.trigger('eventName', [eventParameter1, eventParameter2]);

### Events

#### scaleUpdated

  Triggered when the scale has been updated.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `result` | object | All the scales with related annotations

#### Search results