Class: labelgun

labelgun(hideLabel, showLabel, entries)

new labelgun(hideLabel, showLabel, entries)

create a label gun instance with a hide and show label callback

Parameters:
Name Type Description
hideLabel function the function responsible for hiding the label on hide event
showLabel function the function responsible for showing the label on show event
entries number Higher value relates to faster insertion and slower search, and vice versa
Source:

Methods

(static) getCollisions(id) → {array}

Return a set of collisions (hidden and shown) for a given label

Parameters:
Name Type Description
id string the ID of the label to get
Source:
Returns:
The list of collisions
Type
array

(static) getHidden() → {array}

Return an array of all the hidden labels

Source:
Returns:
An array of hidden labels
Type
array

(static) getLabel(id) → {object}

Convenience function to return a label by ID

Parameters:
Name Type Description
id string the ID of the label to get
Source:
Returns:
The label object for the id
Type
object

(static) getShown() → {array}

Return an array of all shown labels

Source:
Returns:
An array of shown label
Type
array

(static) ingestLabel(boundingBox, id, weight, labelObject, labelName, isDragged) → {undefined}

Creates a label if it does not already exist, then adds it to the tree, and renders it based on whether it can be shown

Parameters:
Name Type Description
boundingBox object The bounding box object with bottomLeft and topRight properties
id string The idea of the label
weight number The weight to compareLabels in the collision resolution
labelObject object The object representing the actual label object from your mapping library
labelName string A string depicting the name of the label
isDragged boolean A flag to say whether the lable is being dragged
Source:
Returns:
Type
undefined

(static) labelHasChanged(id) → {undefined}

Let labelgun know the label has changed in some way (i.e. it's state for example, or that it is dragged)

Parameters:
Name Type Description
id string The id of the label that has changed in some way
Source:
Returns:
Type
undefined

(static) removeLabel(id, label) → {undefined}

Removes label from tree and allLabels object

Parameters:
Name Type Description
id string The label id for the label to remove from the tree
label object The label to remove from the tree
Source:
Returns:
Type
undefined

(static) reset() → {undefined}

Destroy the collision tree and labels

Source:
Returns:
Type
undefined

(static) totalHidden() → {number}

Return the total number of hidden labels

Source:
Returns:
Return total number of labels hidden
Type
number

(static) totalShown() → {number}

Return the total number of shown labels

Source:
Returns:
Return total number of labels shown
Type
number

(static) update(onlyChanges) → {undefined}

Sets all or some of the labels to change and reruns the whole show/hide procedure

Parameters:
Name Type Description
onlyChanges boolean Whether to only update the changes made by labelHasChanged
Source:
Returns:
Type
undefined