Class: SearchPhoton

ol.control. SearchPhoton


new SearchPhoton( [Control])

Search places using the photon API.

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 1000.

options.minLength integer | undefined

minimum length to start searching, default 3

options.maxItems integer | undefined

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

options.handleResponse function | undefined

Handle server response to pass the features array to the list

options.url string | undefined

Url to photon api, default "http://photon.komoot.de/api/"

options.lang string | undefined

Force preferred language, default none

options.position boolean

Search, with priority to geo position, default false

options.getTitle function

a function that takes a feature and return the name to display in the index, default return street + name + contry

Fires:
  • event:select

Extends

Members


_history

Current history

Inherited From:

Methods


ajax(url, data, cback)

Send ajax request

Parameters:
Name Type Description
url string
data *
cback function

a callback function that takes an array of {name, feature} to display in the autocomplete field

Inherited From:

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

Inherited From:

clearHistory()

Remove previous history

Inherited From:

equalFeatures(f1, f2)

Prevent same feature to be drawn twice: test equality

Parameters:
Name Type Description
f1

First feature to compare

f2

Second feature to compare

Overrides:
Returns:
Type
boolean

getHistory()

Get history table

Inherited From:

getInputField()

Get the input field

Inherited From:
Returns:
Type
Element

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

handleResponse(response)

Handle server response to pass the features array to the list

Parameters:
Name Type Description
response any

server response

Overrides:
Returns:

an array of feature

Type
Array.<any>

requestData(s)

Parameters:
Name Type Description
s string

the search string

Overrides:
Returns:

request data (as key:value)

Type
Object

restoreHistory()

Restore history (from the localstorage)

Inherited From:

reverseData(coord)

Get data for reverse geocode

Parameters:
Name Type Description
coord ol.coordinate

reverseGeocode(coord)

Reverse geocode

Parameters:
Name Type Description
coord ol.coordinate
Overrides:

saveHistory()

Save history (in the localstorage)

Inherited From:

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

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:

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: