geoflo

Represents the GeoFlo object that manages all modules.
Returns:
Object - The GeoFlo object with various methods for managing the entire app.

Mixins

Control

Draw

Exploring

Features

Gaming

Layers

Locate

Mesh

Options

Painting

Pinning

Routing

Select

Snapping

Styles

Utilities

Methods

static activateExploring() → {Object}

This function activates exploring nearby streets using the OSRM Router. Fires a custom event 'exploring.activate' with the enabled status and the exploring object.
Returns:
Object - The activated exploring object.

static activatePainting() → {Object}

This function activates painting by free-hand drawing features. Fires a custom event 'painting.activate' with the enabled status and the painting object.
Returns:
Object - The activated Painting object.

static activatePinning() → {Object}

This function activates pinning to snapped features. Allows moving the snapped feature with the current feature. Fires a custom event 'pinning.activate' with the enabled status and the pinning object.
Returns:
Object - The activated pinning object.

static activateRouting() → {Object}

This function activates routing along drawn lines. The router will find the shortest path from start to end. Fires a custom event 'routing.activate' with the enabled status and the routing object.
Returns:
Object - The activated Routing object.

static activateSnapping() → {Object}

This function activates snapping to nearby feature. Snapping options can be set using geoflo.options.snapping Fires a custom event 'snapping.activate' with the enabled status and the snapping object.
Returns:
Object - The activated Snapping object.

static addControl(id) → {void}

Adds a control to the map.
Parameters:
Name Type Description
id string The ID of the control to add.
Returns:
void

static addControls() → {void}

Adds the controls to the map.
Returns:
void

static addFeatures(features, preventZoom) → {Array}

Adds features to the map and optionally zooms to them.
Parameters:
Name Type Description
features Array Array of features to be added to the map.
preventZoom boolean Flag to indicate whether to zoom to the added features.
Returns:
Array - Returns empty Array if no features are provided, otherwise returns the drawn features.

static addFeaturesToMesh(features) → {Array}

Adds features to the mesh index and updates its data.
Parameters:
Name Type Description
features Array An array of features to be added to the mesh.
Returns:
Array - The array of features that were added to the mesh.

static addFeaturesToSelected(features, options) → {Array|Array}

This function adds the provided features to the selected features list, updates the map sources, sets buttons and updates the text.
Parameters:
Name Type Description
features Array The features to be added to the selected features list.
options Object Additional options for adding features.
Properties
Name Type Description
zoom boolean Flag to indicate whether to zoom to the added features.
center boolean Flag to indicate whether to center the map on the added features.
text Object Options for adding text to the features.
Properties
Name Type Attributes Default Description
ids Array <optional>
"selectedFeatures" The IDs of the features to add text to.
field string <optional>
"'text'" The field to use for the text.
layout Object <optional>
The layout options for the text.
Returns:
  • Array - Returns empty Array if no features are provided.
  • Array - The selected features list after adding the provided features.

static cancelEdit(standby, feature) → {boolean}

This function cancels the current edit mode if it is in 'draw' mode and deactivates the editing feature.
Parameters:
Name Type Description
standby boolean Indicates whether the cancel operation is standby.
feature object The feature to be deactivated. If not provided, the editing feature will be used.
Returns:
boolean - Returns false if the current mode is not 'draw', otherwise deactivates the editing feature.

static combineSelectedFeatures() → {void}

Combines selected features based on their geometry type.
Returns:
void

static createPolygon() → {void}

Creates a polygon from selected LineString features and adds it to the map.
Returns:
void

static deactivateExploring() → {boolean}

This function deactivates the exploring mode by deactivating buttons, deleting mesh data, deactivating the exploring mode, and firing an event. Fires a custom event 'exploring.deactivate' with the enable status set to false.
Returns:
boolean - Returns false after deactivating the exploring mode.

static deactivatePainting() → {boolean}

This function deactivates the painting mode by deactivating the buttons, the painting tool, and firing an event. Fires a custom event 'painting.deactivate' with the enable status set to false.
Returns:
boolean - Returns false.

static deactivatePinning() → {boolean}

This function deactivates the pinning feature by deactivating the pinning buttons, the Pinning object, and firing a 'pinning.deactivate' event.
Returns:
boolean - Returns false after deactivating pinning.

static deactivateRouting() → {boolean}

Deactivates the routing functionality by deactivating the routing buttons and the Routing module. Triggers a custom event 'routing.deactivate' with enable set to false.
Returns:
boolean - Returns false after deactivating the routing functionality.

static deactivateSnapping() → {boolean}

This function deactivates the snapping feature by performing various actions. Deletes mesh data, deactivates the snapping buttons, deactivates the Snapping object, and fires a 'snapping.deactivate' event.
Returns:
boolean - Returns false after deactivating the snapping feature.

static deleteMeshData()

Deletes the mesh data by updating it with an empty array and triggering a 'snapping.delete' event with the features from the mesh index.

static deleteUserData() → {void}

This function allows the user to delete selected features or all features based on confirmation prompts. It updates the map data and resets various properties.
Returns:
void - - No return value.

static disable() → {Object}

This function disables the map by clearing modes, setting enabled to false, resetting mode to null, resetting options to default, firing a 'map.disable' event, enabling double click zoom, removing event listeners, layers, and controls.
Returns:
Object - Returns the current instance of the map object.

static editFeature(id, options) → {Object}

This function allows editing a feature by providing its ID or using the currently selected feature. It triggers a 'feature.edit' event and sets the mode to 'edit'.
Parameters:
Name Type Description
id string The ID of the feature to edit.
options Object Additional options for editing the feature.
Properties
Name Type Description
feature Object The feature object to edit.
Returns:
Object - The edited feature.

static enable(type, options) → {Object}

This function enables the map interaction mode based on the provided type and options. It sets the mode to 'select' or 'draw' depending on the type parameter, initializes options, controls, modes, and triggers events.
Parameters:
Name Type Description
type string The type of interaction mode to enable ('select' or 'draw').
options Object Additional options for the interaction mode (default: {}).
Returns:
Object - - The current instance of the map with the enabled interaction mode.

static fire(type, detail) → {boolean}

Fires an event with the specified GeoFlo type and detail. Detail is an Object type.
Parameters:
Name Type Description
type string The type of the event to fire.
detail any Additional details to include with the event.
Returns:
boolean - Returns true if the event was successfully fired, false otherwise.

static forEachSelectedFeature(handler) → {Array}

Iterates over each selected feature and applies a handler function to it.
Parameters:
Name Type Description
handler function The function to be applied to each selected feature.
Returns:
Array - The array of selected features after applying the handler function.

static getButtons(id) → {object|boolean}

Retrieves the buttons associated with a specific control or all buttons from the controls.
Parameters:
Name Type Description
id string The ID of the button to retrieve. If not provided, retrieves all buttons.
Returns:
object | boolean - - Returns an object containing the buttons if found, or false if controls are not available.

static getColors() → {Array}

This function retrieves the colors from the options object.
Returns:
Array - The colors array from the options object.

static getCommonGeometryType() → {string|null}

This function returns the common geometry type of the selected features. If all selected features have the same geometry type, it returns that type. If the selected features have different geometry types, it returns "illegal".
Returns:
string | null - The common geometry type or null if different types are present.

static getControlIds() → {Array}

Retrieves the control IDs from the controls array.
Returns:
Array - An array of control IDs.

static getDrawnFeatures() → {Array}

Retrieves the drawn features from the Features object.
Returns:
Array - An array of drawn features.

static getFeatureById(id) → {object}

Retrieves a feature by its ID from the Features object.
Parameters:
Name Type Description
id string The ID of the feature to retrieve.
Returns:
object - Returns the feature object if found, otherwise an empty object.

static getFeaturesByLayer(source, lngLat, radiusInKm, filter) → {Array}

This function queries the map for features within a specified radius around a given location from a specific source layer.
Parameters:
Name Type Description
source string The source layer to query features from.
lngLat LngLat The longitude and latitude coordinates of the center point for the query.
radiusInKm number The radius in kilometers within which to search for features.
filter Object Optional filter object to apply to the query.
Returns:
Array - An array of features that match the query criteria.

static getHotFeature() → {Object}

Retrieves the hot feature being drawn or edited.
Returns:
Object - The hot feature object.

static getMap() → {Object}

Retrieves the map property from the Map object.
Returns:
Object - The map property of the Map object.

static getMode() → {object}

Retrieves the current mode of the object. Either 'GeoFlo.Select' or 'GeoFlo.Draw'.
Returns:
object - The current mode of the object.

static getModes(mode) → {Array|Object}

Retrieves the modes based on the provided mode parameter. If a mode is specified, it returns the mode that can handle the input mode. If no mode is specified, it returns all available modes.
Parameters:
Name Type Description
mode string The mode to be checked against available modes.
Returns:
Array | Object - - An array of all available modes if no mode is specified, or the mode object that can handle the input mode.

static getRenderedDrawnFeatures(lngLat, radiusInKm, filter) → {Array}

This function queries the map for rendered drawn features based on the provided parameters.
Parameters:
Name Type Description
lngLat Object The longitude and latitude coordinates.
radiusInKm number The radius in kilometers for the search.
filter Object Optional filter object to apply to the query.
Returns:
Array - An array of features within the specified radius around the given coordinates.

static getRenderedFeatures(lngLat, radiusInKm, filter) → {Array.<object>}

Retrieves rendered features within a specified radius around a given longitude and latitude, based on a filter.
Parameters:
Name Type Description
lngLat Array.<number> An array containing the longitude and latitude coordinates.
radiusInKm number The radius in kilometers within which to search for features.
filter object An optional filter object to apply when retrieving features.
Returns:
Array.<object> - An array of rendered features that match the criteria.

static getRenderedSnapFeatures(lngLat, radiusInKm, filter) → {Array}

Retrieves rendered mesh index features within a specified radius around a given point on the map.
Parameters:
Name Type Description
lngLat Object The longitude and latitude coordinates of the center point.
radiusInKm number The radius in kilometers within which to search for features.
filter Object Optional filter to apply to the query.
Returns:
Array - An array of features that fall within the specified radius around the given point.

static getSelectedFeatureIds() → {Array}

Retrieves the IDs of selected features.
Returns:
Array - An array of feature IDs.

static getSelectedFeatures() → {Array}

Retrieves the selected features stored in the selectedFeatures array.
Returns:
Array - An array containing the selected features.

static getSelectedFeaturesBbox() → {Array.<number>}

Retrieves the bounding box of the selected features.
Returns:
Array.<number> - The bounding box coordinates [minX, minY, maxX, maxY].

static getSelectedPropertyNames() → {Array}

Retrieves the unique property names of selected features excluding the ID property.
Returns:
Array - An array of unique property names.

static getSelectedPropertyValues() → {Object}

Retrieves the properties of selected features excluding the property with the specified ID.
Returns:
Object - An object containing the properties of selected features.

static getSnapFeatures() → {Array}

Retrieves the snap features from the mesh index.
Returns:
Array - An array of snap features.

static hasControls() → {boolean}

This function checks if the object has controls by verifying the existence and length of the controls array.
Returns:
boolean - Returns true if the object has controls, false otherwise.

static hasSelection() → {boolean}

This function determines whether there is a selection of features.
Returns:
boolean - Returns true if there is a selection of features, otherwise false.

static hasSingleSelection() → {boolean}

This function checks if there is only one selected feature.
Returns:
boolean - Returns true if there is a single selection, false otherwise.

static hideFeatures(ids) → {Array}

Hides features by setting their state to hidden and firing a 'features.hide' event.
Parameters:
Name Type Description
ids Array An array of feature IDs to be hidden.
Returns:
Array - The features that were hidden.

static hideSelectedFeatures() → {void}

This function hides the selected features on the map by moving them to a hidden features array and updating the map sources.
Returns:
void

static init(accessToken, optionsopt, onReady) → {Promise.<Object>}

Initializes the map component with the provided options and a callback function when ready.
Parameters:
Name Type Attributes Default Description
accessToken string The Mapbox Access Token to be used for the map component.
options Object <optional>
{} The options object for configuring GeoFlo. This object will be assigned to geoflo.Options
onReady function The callback function to be executed when the map is ready.
Returns:
Promise.<Object> - A promise that resolves to the map object after initialization.

static loadFeatures() → {void}

This function creates an input element of type file, allows multiple file selection, and triggers a file selection event. It then processes the selected files by calling the Utilities.processFiles function.
Returns:
void

static moveFeature(feature, direction) → {Array}

This function calculates the new coordinates of a feature based on the direction and distance provided. NOT WORKING YET.
Parameters:
Name Type Description
feature Object The feature object to be moved.
direction number The direction in which the feature should be moved (1 for forward, -1 for backward).
Returns:
Array - An array of new coordinates for the feature after moving.

static moveMapAlongLine(line) → {void}

This function animates the movement of the map along a specified line. The camera follows the route, ensuring synchronized movement.
Parameters:
Name Type Description
line Array The line representing the route on the map.
Returns:
void

static moveSelectedFeatures(direction) → {boolean}

This function checks if moving is enabled and if there are selected features of LineString type. If so, it offsets the selected LineString features by the specified distance in the provided direction.
Parameters:
Name Type Description
direction number The direction in which to move the selected features (1 for forward, -1 for backward).
Returns:
boolean - Returns false if moving is not enabled or there are no selected LineString features.

static off(type, callback) → {boolean}

Removes an event listener from the map based on the provided GeoFlo event type and callback. Callback function must have a name.
Parameters:
Name Type Description
type string The type of event to remove the listener from.
callback function The callback function to be removed as the event listener.
Returns:
boolean - Returns true if the event listener was successfully removed, false otherwise.

static on(type, callback) → {boolean}

Registers a callback function to be executed for a specific GeoFlo event type.
Parameters:
Name Type Description
type string The type of event to listen for.
callback function The callback function to be executed when the event occurs.
Returns:
boolean - Returns true if the event listener was successfully attached, false otherwise.

static once(type, callback) → {boolean}

Registers a callback function to be executed only once for a specific GeoFlo event type.
Parameters:
Name Type Description
type string The type of event to listen for.
callback function The callback function to be executed when the event occurs.
Returns:
boolean - Returns true if the callback is successfully registered to be executed once, otherwise false.

static redraw() → {Promise.<boolean>}

Redraws the map by refreshing layers, updating event listeners, and disabling double click zoom.
Returns:
Promise.<boolean> - Returns a promise that resolves to true if the map is successfully redrawn, false otherwise.

static refresh() → {Promise.<boolean>}

Refreshes the content by redrawing it asynchronously.
Returns:
Promise.<boolean> - Returns a Promise that resolves to a boolean value.

static refreshMeshData()

This function refreshes the mesh data by triggering a 'snapping.refresh' event with the current mesh features.

static removeControl(id) → {void}

Removes a control from the map.
Parameters:
Name Type Description
id string The ID of the control to remove.
Returns:
void

static removeControls() → {void}

Removes the controls from the map.
Returns:
void

static removeEventListeners - Removes event listeners from the map and other elements.(geoflo) → {Object}

This module handles various map and user interaction events for the geoflo application.
Parameters:
Name Type Description
geoflo Object The geoflo instance to which the events are bound.
Returns:
Object - An object containing methods to add and remove event listeners.

static removeFeature(id) → {boolean}

Removes a feature from the Features collection and fires an event if edit mode is not enabled. Fires a custom event 'feature.delete' with the ID and feature object.
Parameters:
Name Type Description
id string The ID of the feature to be removed.
Returns:
boolean - - Returns true if the feature was successfully removed, otherwise false.

static removeFeatures(layers)

Removes specified features from the map. If no layers are provided, all features are removed. If the layers parameter is not an array, the function returns false.
Parameters:
Name Type Description
layers Array An array of layers to remove features from.

static removePopup() → {boolean}

Removes the popup element from the DOM.
Returns:
boolean - Returns true if the popup was successfully removed, false otherwise.

static removeSelection(id) → {number}

Removes the selection of features based on the provided feature ID. If no ID is provided, all selected features are deselected.
Parameters:
Name Type Description
id string The ID of the feature to be deselected.
Returns:
number - The number of features that were deselected.

static saveEdit() → {any}

Saves the edited feature using the currentModes saveEdit method.
Returns:
any - The result of the saveEdit method of the current mode.

static saveFeatures(layer) → {void}

This function prepares the features of a layer for export in different formats such as KMZ, GPX, and GeoJSON. It styles the features, creates necessary metadata, and generates the export files.
Parameters:
Name Type Description
layer Object The layer object containing the features to be exported.
Returns:
void

static selectFeature(id) → {boolean|Object}

Selects a feature by its ID and returns the selection result.
Parameters:
Name Type Description
id string The ID of the feature to be selected.
Returns:
boolean | Object - Returns false if the feature is not found, otherwise returns the result of the selection.

static setActiveButton(id) → {boolean}

Sets the active button with the specified id in the controls array.
Parameters:
Name Type Description
id string The id of the button to set as active.
Returns:
boolean - Returns false if the controls array is empty or undefined.

static setButtons() → {boolean}

This function resets the active buttons and activates the Select button.
Returns:
boolean - Returns true if the Select button is successfully set, false otherwise.

static setCenterMarker(options) → {Object|boolean}

This function sets a marker at the center of the map. It allows customization of the marker icon and behavior.
Parameters:
Name Type Description
options Object Options object for customizing the center marker.
Properties
Name Type Attributes Description
remove boolean <optional>
If true, removes the center marker.
transform boolean <optional>
If true, applies transformation to the center marker.
gamepad boolean <optional>
If true, applies gamepad settings to the center marker.
dontAdd boolean <optional>
If true, does not add the center marker.
noRemove boolean <optional>
If true, prevents the center marker from being removed.
Returns:
Object | boolean - Returns the center marker object if successfully added or updated, or false if not applicable.

static setColors(colors) → {Object}

This function sets the colors for the map based on the provided object. It merges the provided colors with the existing colors and updates the theme.
Parameters:
Name Type Description
colors Object The colors object to set for the map.
Returns:
Object - The updated colors object after setting the colors.

static setIcon(event) → {void}

This function determines the appropriate icon to display based on the user's following status and navigation compass icon.
Parameters:
Name Type Description
event Event The event for which the icon is being set.
Returns:
void
Deprecated:
  • Yes

static setLayers(layers, options) → {Promise}

Sets custom layers and optionally resets features based on the provided options.
Parameters:
Name Type Description
layers Array An array of layers to be set.
options Object An object containing options for setting layers.
Properties
Name Type Description
reset boolean Indicates whether to reset features before setting layers.
Returns:
Promise - A promise that resolves when the custom layers have been set.
Author:
  • Solutegrate

static setMapClass(name) → {boolean}

Sets a specific mouse class on the map container element based on the provided name. Removes any existing classes starting with "mouse-" before adding the new class.
Parameters:
Name Type Description
name string The name of the class to be added (without the "mouse-" prefix).
Returns:
boolean - Returns false if the name is empty, otherwise adds the class and returns undefined.

static setMeshFeatures(features) → {Object}

Updates the mesh data with the provided features and returns the updated mesh. Adds a mesh index if it does not exist.
Parameters:
Name Type Description
features Array An array of features to update the mesh with.
Returns:
Object - The updated mesh after setting the features.

static setMode(options) → {Object}

This function allows the user to set the mode of the map editor with various options.
Parameters:
Name Type Description
options Object The options object for setting the mode.
Properties
Name Type Attributes Default Description
mode string <optional>
'select' The mode to set (default: select).
type string <optional>
'LineString' The type of the mode (default: LineString).
feature Object <optional>
The feature to edit in the mode.
Returns:
Object - The current mode after setting it based on the options.

static setOpacity(value)

This function takes a numeric value and sets the opacity of specified layers on the map to that value.
Parameters:
Name Type Description
value number The opacity value to set for the layers.

static setOptions(options) → {Object}

Sets the options for the object by merging the provided options with the existing ones.
Parameters:
Name Type Description
options Object The options to be merged with the existing options.
Returns:
Object - The updated options object after merging.

static setSelectedFeatures(features) → {boolean}

This function updates the selected features on the map with the provided array of features.
Parameters:
Name Type Description
features Array An array of features to set as selected.
Returns:
boolean - Returns false if the features array is empty.

static setTheme(colors) → {void}

Sets the theme colors for the control.
Parameters:
Name Type Description
colors Object An object containing the theme colors.
Returns:
void

static updateFeatures(features) → {Array}

Updates the features of a layer based on the provided features.
Parameters:
Name Type Description
features Array An array of features to update the layer with.
Returns:
Array - The updated features of the layer.

static updateMeshData(features, reset) → {Object}

This function updates the mesh data on the map by adding new features to the mesh index and updating the map source with the new data. If the mesh index is not available or the reset flag is set to true, the mesh index is reset before adding new features.
Parameters:
Name Type Description
features Array An array of features to be added to the mesh index.
reset boolean A flag indicating whether to reset the mesh index before adding new features.
Returns:
Object - The updated feature collection that was set on the map source.

static updateOrientation(options) → {string}

Updates the orientation of the user based on the provided options.
Parameters:
Name Type Description
options Object An object containing the options for updating the orientation.
Returns:
string - The location of the user after updating the orientation.

static updateSelectedProperties(newProperties, propertiesToKeep)

This function updates the selected properties of features based on the new properties provided while keeping specified properties.
Parameters:
Name Type Description
newProperties Object The new properties to update the features with.
propertiesToKeep Array An array of property names to keep while updating the features.

static zoomToFeatures(features, options) → {boolean}

This function zooms to the provided features on the map. If no features are provided, it zooms to the selected features, cold features, or the map extent if no other features are available.
Parameters:
Name Type Description
features Array The features to zoom to on the map.
options Object Additional options for zooming (default: {}).
Returns:
boolean - Returns false if no features are available to zoom to.