This mixin provides the exploring functionality for the GeoFlo application. It allows users to explore features on the map by creating a buffer around the feature and snapping to nearby features.
Methods
-
static activate() → {void}
-
Activates by setting the 'enabled' property to true and enabling the 'exploring' option.
Returns:
void -
static deactivate()
-
This function sets the 'enabled' and 'currentMatch' properties to false, and disables the 'exploring' option in the context.
-
static getFeatures(bounds) → {Promise.<Array>}
-
Retrieves features based on the provided bounds using Overpass API.
Parameters:
Name Type Description bounds
Array An array containing the bounding box coordinates [minLon, minLat, maxLon, maxLat]. Returns:
Promise.<Array> - An array of GeoJSON features within the specified bounds. -
static getMatch(coords, options) → {Promise.<(Array|Boolean)>}
-
This function takes an array of coordinates and optional options to fetch a matched route from the OSRM API.
Parameters:
Name Type Description coords
Array An array of coordinates to match the route against. options
Object Optional parameters for customization. Properties
Name Type Description feature
Object Optional feature to match against. radius
Number | function Optional radius for matching or a function to calculate it. profile
String Optional profile for routing (default: 'driving'). set
Boolean Optional flag to set the feature if matching is successful. Returns:
Promise.<(Array|Boolean)> - The matched route response object or false if no coordinates are provided or matching fails. -
static getRoute(coords, options) → {Promise.<(Array|Boolean)>}
-
Retrieves a route based on the provided coordinates using the OSRM routing service.
Parameters:
Name Type Description coords
Array Array of coordinates representing the route. options
Object Additional options for the route calculation. Properties
Name Type Description feature
Object Feature object to use for the route calculation. profile
String Profile type for the route calculation (default: 'driving'). set
Boolean Flag to indicate whether to set the route as a feature. Returns:
Promise.<(Array|Boolean)> - The route response object or false if no coordinates are provided or the route calculation fails. -
static setFeature(coords, options) → {Object}
-
This function creates a line feature using the given coordinates and updates the current match based on the options. It also triggers an event and updates the source data on the map.
Parameters:
Name Type Description coords
Array The coordinates to create the line feature. Default is an empty array. options
Object Additional options for setting the feature, such as the starting point. Default is an empty object. Returns:
Object - The updated feature based on the provided coordinates and options. -
static setFeatures(coords, optionsopt) → {boolean}
-
This function sets features on the map based on the provided coordinates and options. It calculates the buffer based on the map zoom level and retrieves features within the buffer area. If routing is enabled, it calculates the route between two points.
Parameters:
Name Type Attributes Default Description coords
Array.<number> The coordinates to set features around. options
Object <optional>
{} Additional options for setting features. Returns:
boolean - Returns false if the function is not executed successfully.