Measure

ol-ishare/interaction/measure~ Measure

Measure interaction for measuring lengths or areas on a map.

While the measurement is being drawn, a temporary 'sketch' will be shown on an overlay vector layer. To style this use .getOverlay().setStyle().

Constructor

new Measure(options)

Parameters:
Name Type Description
options Object

ol/interaction/Draw options. Note that like ol/interaction/Draw, the options.type 'option' is required. Extended with the following extra settings

Properties
Name Type Attributes Default Description
persist Boolean <optional>
true

Whether to persist all measurements (default Draw behaviour) or to clean up previous measurements when starting a new one

Extends

Methods

getPersistance() → {Boolean}

Returns:

Whether previous measurements stay in the associated source or collection (if configured) when a new measurement is started

Type
Boolean

getSource() → {ol/Source/Vector}

Returns:

The vector source in use (if configured)

Type
ol/Source/Vector

getFeaturesCollection() → {ol/Collection.<ol/Feature>}

Returns:

The collection of features in use (if configured)

Type
ol/Collection.<ol/Feature>

(static) formatLength(length) → {string}

Formats length value, converts metres to kilometres when value is large.

Parameters:
Name Type Description
length Number

Length in metres

Returns:

The formatted length.

Type
string

(static) formatArea(area) → {string}

Formats area value, converts square metres to square kilometres when value is large.

Parameters:
Name Type Description
area Number

Area in square metres

Returns:

Formatted area.

Type
string

(static) addMeasurements(feature) → {ol/Feature}

Uses Measure formatting static methods to add measurement properties to a feature

Parameters:
Name Type Description
feature ol/Feature

Feature for which to calculate and update with measurements

Returns:

Feature with added measurement properties, available via {ol/Feature#getProperties}: measurement, will either be 'area' or 'length'.

Additional 'area' measurements: area - numeric area value formattedArea - formatted area text perimeter - numeric length of perimeter formattedPerimeter - formatted perimeter text

Additional 'length' measurements: length - numeric length value formattedLength - formatted length text

Type
ol/Feature

Events

measurementinterim

Properties:
Name Type Description
type string

'measurementinterim'

target module:ol-ishare/interaction/measure~Measure

The Measure Interaction that triggered the event

feature ol/Feature

Sketch feature object with additional measurement properties.

Fired when the measurement sketch feature has a new segment added to it

Type:

measurementdraft

Properties:
Name Type Description
type string

'measurementdraft'

target module:ol-ishare/interaction/measure~Measure

The Measure Interaction that triggered the event

feature module:ol/Feature~Feature

The sketch feature with measurement properties

Fired when the measurement sketch updates - typically whenever the mouse moves while Measure is active.

Type:

measurementfinal

Properties:
Name Type Description
type string

'measurementfinal'

target module:ol-ishare/interaction/measure~Measure

The Measure Interaction that triggered the event

feature module:ol/Feature~Feature

The sketch feature with measurement properties

Fired when the measurement feature is finished

Type: