new SearchJSON(options)
This is the base class for search controls that use a json service to search features. You can use it for simple custom search or as base to new class.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
any | extend ol.control.Search options Properties
|
Fires:
- event:select
Extends
Methods
-
ajax(url, onsuccess, onerror)
-
Send an ajax request (GET)
Parameters:
Name Type Description url
string onsuccess
function callback
onerror
function callback
-
autocomplete(s, cback)
-
Autocomplete function (ajax request to the server)
Parameters:
Name Type Description s
string search string
cback
function a callback function that takes an array of {name, feature} to display in the autocomplete field
- Overrides:
-
clearHistory()
-
Remove previous history
- Inherited From:
-
equalFeatures(f1, f2)
-
Test if 2 features are equal
Parameters:
Name Type Description f1
any f2
any - Inherited From:
Returns:
- Type
- boolean
-
getHistory()
-
Get history table
- Inherited From:
-
getTitle(f)
-
Returns the text to be displayed in the menu
Parameters:
Name Type Description f
any feature to be displayed
- Inherited From:
Returns:
the text to be displayed in the index, default f.name
- Type
- string
-
handleResponse(response)
-
Handle server response to pass the features array to the display list
Parameters:
Name Type Description response
any server response
Returns:
an array of feature
- Type
- Array.<any>
-
requestData(s)
-
Parameters:
Name Type Description s
string the search string
Returns:
request data (as key:value)
- Type
- Object
-
restoreHistory()
-
Restore history (from the localstorage)
- Inherited From:
-
saveHistory()
-
Save history (in the localstorage)
- Inherited From:
-
search()
-
Force search to refresh
- Inherited From:
-
select(f)
-
A ligne has been clicked in the menu > dispatch event
Parameters:
Name Type Description f
any the feature, as passed in the autocomplete
- Inherited From:
-
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: