new Query(term, confirmed)
Initializes the search query, setting up UI elements and triggering the 'search' hook.
Parameters:
Name | Type | Description |
---|---|---|
term |
string | The search term. |
confirmed |
boolean | Indicates if the search is confirmed (e.g., by pressing Enter). |
Methods
-
static addPortalResult(data, guid)
-
Adds a search result for a portal to the search query results.
Parameters:
Name Type Description data
Object The portal data for the search result. This includes information such as title, team, level, health, etc.
guid
string GUID if the portal.
-
static addResult(result)
-
Adds a search result to the query and triggers re-rendering of the results list.
Parameters:
Name Type Description result
IITC.search.Query.SearchResult The search result to add, including title, position, and interactions.
-
private, static handleKeyPress(ev, result)
-
Handles keyboard interactions for selecting a result with Enter or Space keys.
Parameters:
Name Type Description ev
Event The keyboard event.
result
Object The result being interacted with.
-
private, static handleResultInteraction(result, event)
-
Manages interactions with search results, such as clicks, hovers, and keyboard events.
Parameters:
Name Type Description result
Object The result being interacted with.
event
Event The event associated with the interaction.
-
private, static onResultHoverEnd()
-
Handles the end of a hover event, removing the hover layer from the map.
-
private, static onResultHoverStart(result)
-
Starts a hover interaction on a search result, displaying its layer on the map.
Parameters:
Name Type Description result
Object The result being hovered over.
-
private, static onResultSelected(result, event)
-
Handles the selection of a search result, adjusting the map view and adding its layer to the map.
Parameters:
Name Type Description result
Object The selected search result object.
event
Event The event associated with the selection.
-
private, static removeHoverResult()
-
Ends a hover interaction by removing the hover layer from the map if it is not selected.
-
private, static removeSelectedResult()
-
Removes the currently selected search result from the map and performs necessary cleanup.
-
private, static renderResults()
-
Renders all search results through the resultsView class and sets up event handling for each result.
-
private, static resultLayer(result) → {L.Layer}
-
Creates and returns a map layer for the given search result, which could include markers or shapes.
Parameters:
Name Type Description result
Object The search result object.
Returns:
L.Layer -- The generated layer for the result.
-
private, static show()
-
Displays the search query results in the specified resultsView container.
-
private, static show()
-
Hides and removes the current search results, clearing selection and hover states.
Type Definitions
-
onRemoveCallback(result) → {void}
-
Parameters:
Name Type Description result
IITC.search.Query.SearchResult The search result that is being removed.
Returns:
void -- No return value.
-
onSelectedCallback(result, event) → {boolean}
-
Parameters:
Name Type Description result
IITC.search.Query.SearchResult The selected search result.
event
Event The event that triggered the selection.
Returns:
boolean -- Returns true to prevent map repositioning.
-
SearchResult
-
Properties:
Name Type Attributes Description title
string The label for this result (HTML-formatted).
description
string <optional>
Secondary information for this result (HTML-formatted).
position
L.LatLng <optional>
Position of this result.
bounds
L.LatLngBounds <optional>
Bounds of this result.
layer
L.Layer | null <optional>
Layer to be added to the map on result selection.
icon
string <optional>
URL to a 12x12px icon for the result list.
onSelected
IITC.search.Query.onSelectedCallback <optional>
Handler called when result is selected. May return
true
to prevent the map from being repositioned. You may reposition the map yourself or do other work.onRemove
IITC.search.Query.onRemoveCallback <optional>
Handler called when result is removed from map. (because another result has been selected or the search was cancelled by the user).