.search.Query(term, confirmed)

new Query(term, confirmed)

Represents a search query.

Parameters:
Name Type Description
term string

The search term.

confirmed boolean

Indicates if the search is confirmed (e.g., by pressing Enter).

Methods

addResult(result)

Adds a search result to this query.

Parameters:
Name Type Description
result Object

The search result object to add.

hide()

Hides the search query results and cleans up.

init()

Initializes the search query, setting up the DOM elements and triggering the 'search' hook.

onResultHoverEnd(result, ev)

Handles the end of a hover over a search result. Removes the hover result layer from the map.

Parameters:
Name Type Description
result Object

The search result object being hovered over.

ev Event

The event associated with the hover end.

onResultHoverStart(result, ev)

Handles the start of a hover over a search result. Adds the layer for the result to the map if not already selected.

Parameters:
Name Type Description
result Object

The search result object being hovered over.

ev Event

The event associated with the hover start.

onResultSelected(result, ev)

Handles the selection of a search result, including map view adjustments and layer management.

Parameters:
Name Type Description
result Object

The selected search result object.

ev Event

The event associated with the selection.

removeHoverResult()

Removes the hover result layer from the map unless it's the selected result.

removeSelectedResult()

Removes the currently selected search result from the map and performs cleanup.

resultLayer(result) → {L.Layer}

Creates and returns a layer for the given search result, which could be markers or shapes on the map.

Parameters:
Name Type Description
result Object

The search result object.

Returns:
L.Layer -

The layer created for this result.

show()

Displays the search query results in the search wrapper.