This module provides the pinning functionality for the Geoflo application. It allows users to pin features to the map by creating a buffer around the feature and snapping to nearby features.
Methods
-
static activate() → {void}
-
Activates the feature by setting the enabled flag to true and enabling pinning in the options.
Returns:
void -
static deactivate()
-
This function deactivates pinning by setting enabled to false, disabling pinning in options, clearing buffer, pinableFeatures, and pinningFeatures, and resetting coldFeatures.
-
static getFeatures() → {Array}
-
Retrieves the features from the pinnedFeatures array in the context object.
Returns:
Array - An array of features extracted from the pinnedFeatures array. -
static getNearByFeatures(coords) → {Array.<Object>}
-
This function calculates the radius based on the map zoom level and retrieves nearby features within that radius.
Parameters:
Name Type Description coords
Array.<number> The coordinates [longitude, latitude] to find nearby features. Returns:
Array.<Object> - An array of nearby features with their IDs, types, indices, and feature objects. -
static resetFeatures() → {boolean}
-
Resets the updated features by adding them to the canvas context.
Returns:
boolean - Returns false if there are no updated features to reset. -
static setBuffer(coords) → {Object|boolean}
-
This function creates a buffer around the provided coordinates based on the pinning buffer option.
Parameters:
Name Type Description coords
Array.<number> The coordinates [longitude, latitude] to create the buffer around. Returns:
Object | boolean - Returns the buffer object containing the feature, radius, and coordinates if successful, otherwise false. -
static setFeatures(coords) → {Array}
-
Sets the pinable features based on the provided coordinates and fires an event.
Parameters:
Name Type Description coords
Object The coordinates to determine nearby features. Returns:
Array - - An array of pinable features. -
static updateFeatures() → {boolean}
-
This function updates the features if the pinning functionality is enabled. It updates the pinable features, pinned features, and triggers events accordingly.
Returns:
boolean - Returns false if the pinning functionality is not enabled, otherwise returns the updated pinning features.