Class: SearchFeature

ol.control. SearchFeature

Search features.


new SearchFeature( [Control])

Parameters:
Name Type Argument Description
Control Object <optional>

options.

options.className string

control class name

options.target Element | string | undefined

Specify a target if you want the control to be rendered outside of the map's viewport.

options.label string | undefined

Text label to use for the search button, default "search"

options.placeholder string | undefined

placeholder, default "Search..."

options.typing number | undefined

a delay on each typing to start searching (ms), default 300.

options.minLength integer | undefined

minimum length to start searching, default 1

options.maxItems integer | undefined

maximum number of items to display in the autocomplete list, default 10

options.property string | undefined

a property to display in the index, default 'name'.

options.getTitle function

a function that takes a feature and return the name to display in the index, default return the property

options.getSearchString function | undefined

a function that take a feature and return a text to be used as search string, default geTitle() is used as search string

options.sort function | undefined

a function to sort autocomplete list. Takes 2 features and return 0, -1 or 1.

Fires:
  • event:select

Extends

Members


_history

Current history

Inherited From:
Overrides:

Methods


_getTitleTxt(f)

Returns title as text

Parameters:
Name Type Description
f any

feature to be displayed

Inherited From:
Overrides:
Returns:
Type
string

autocomplete(s, max, cback)

Autocomplete function

Parameters:
Name Type Description
s string

search string

max int

max

cback function

a callback function that takes an array to display in the autocomplete field (for asynchronous search)

Overrides:
Returns:

an array of search solutions or false if the array is send with the cback argument (asnchronous)

Type
Array.<any> | false

clearHistory()

Remove previous history

Inherited From:
Overrides:

collapse( [b])

Collapse the search

Parameters:
Name Type Argument Default Description
b boolean <optional>
true
Inherited From:
Overrides:

equalFeatures(f1, f2)

Test if 2 features are equal

Parameters:
Name Type Description
f1 any
f2 any
Inherited From:
Overrides:
Returns:
Type
boolean

getHistory()

Get history table

Inherited From:
Overrides:

getInputField()

Get the input field

Inherited From:
Overrides:
Returns:
Type
Element

getSearchString(f)

Return the string to search in

Parameters:
Name Type Description
f ol.Feature

the feature

Returns:

the text to be used as search string

Type
string

getSource()

Get the source

Returns:
Type
ol.source.Vector

getTitle(f)

Returns the text to be displayed in the menu

Parameters:
Name Type Description
f ol.Feature

the feature

Overrides:
Returns:

the text to be displayed in the index

Type
string

restoreHistory()

No history avaliable on features

Overrides:

reverseGeocode(coord, cback)

Reverse geocode

Parameters:
Name Type Description
coord ol.coordinate
cback function | undefined

a callback function, default trigger a select event

Inherited From:
Overrides:

saveHistory()

No history avaliable on features

Overrides:

Force search to refresh

Inherited From:
Overrides:

select(f, reverse, coord, options)

A line has been clicked in the menu > dispatch event

Parameters:
Name Type Description
f any

the feature, as passed in the autocomplete

reverse boolean

true if reverse geocode

coord ol.coordinate
options *

options passed to the event

Inherited From:
Overrides:

setInput(value, search)

Set the input value in the form (for initialisation purpose)

Parameters:
Name Type Description
value string
search boolean

to start a search

Inherited From:
Overrides:

setMap(map)

Remove the control from its current map and attach it to the new map. Subclasses may set up event handlers to get notified about changes to the map here.

Parameters:
Name Type Description
map ol.Map

Map.

Inherited From:
Overrides:

setSortFunction(sort)

Set function to sort autocomplete results

Parameters:
Name Type Description
sort function

a sort function that takes 2 features and returns 0, -1 or 1


setSource(source)

Get the source

Parameters:
Name Type Description
source ol.source.Vector