Geoportal Extension for OpenLayers API Reference

Class: SearchEngine

ol.control.SearchEngine

SearchEngine control

new SearchEngine(options)

OpenLayers/Controls/SearchEngine.js, line 81
Name Type Description
options Object

control options

Name Type Default Description
apiKey String optional

API key. The key "calcul" is used by default.

ssl Boolean true optional

use of ssl or not (default true, service requested using https protocol)

collapsed Boolean true optional

collapse mode, true by default
Value possible : auto or zoom level.
Possible to overload it with a function :
zoomTo : function (info) {
// do some stuff...
return zoom;
}

placeholder String optional

Placeholder in search bar. Default is "Rechercher un lieu, une adresse".

displayMarker Boolean true optional

set a marker on search result, defaults to true.

markerStyle String "lightOrange" optional

Marker style. Currently possible values are "lightOrange" (default value), "darkOrange", "red" and "turquoiseBlue".

displayAdvancedSearch Boolean true optional

False to disable advanced search tools (it will not be displayed). Default is true (displayed)

advancedSearch Object optional

advanced search options for geocoding (filters). Properties can be found among geocode options.filterOptions (see Gp.Services.geocode)

resources Object optional

resources to be used by geocode and autocompletion services :

Name Type Description
geocode String optional

resources geocoding, by default : "location"

autocomplete Array optional

resources autocompletion, by default : ["PositionOfInterest", "StreetAddress"]

displayAdvancedSearch Boolean true optional

False to disable advanced search tools (it will not be displayed). Default is true (displayed)

advancedSearch Object optional

advanced search options for geocoding (filters). Properties can be found among geocode options.filterOptions (see Gp.Services.geocode)

geocodeOptions Object {} optional

options of geocode service (see Gp.Services.geocode)

autocompleteOptions Object {} optional

options of autocomplete service (see Gp.Services.autoComplete

Name Type Default Description
serviceOptions Object optional

options of autocomplete service

triggerGeocode Boolean false optional

trigger a geocoding request if the autocompletion does not return any suggestions, false by default

triggerDelay Number 1000 optional

waiting time before sending the geocoding request, 1000ms by default

zoomTo Sting | Numeric | function optional

zoom to results, by default, current zoom.

Fires:
  • searchengine:autocomplete:click
  • searchengine:geocode:click
Example
var SearchEngine = ol.control.SearchEngine({
     apiKey : "CLEAPI",
     collapsed : true,
     resources : {
         geocode : ["StreetAddress", "PositionOfInterest"],
         autocomplete : ["StreetAddress"]
     },
     advancedSearch : {
         PositionOfInterest : [{name : "municipality", title : "Ville"}],
         StreetAddress : [{...}]
     },
     geocodeOptions : {},
     autocompleteOptions : {}
 });

 SearchEngine.on("searchengine:autocomplete:click", function (e) {
   console.warn("autocomplete", e.location);
 });
 SearchEngine.on("searchengine:geocode:click", function (e) {
   console.warn("geocode", e.location);
 });

Extends

  • ol.control.Control

Members

collapsed

{Boolean} specify if searchEngine control is collapsed (true) or not (false)

Methods

getCollapsed(){Boolean}

OpenLayers/Controls/SearchEngine.js, line 161

Returns true if widget is collapsed (minimized), false otherwise

Returns:
- true if widget is collapsed

getData(){Object}

OpenLayers/Controls/SearchEngine.js, line 188

Get locations data from geocode service

Returns:
- locations

setCollapsed(collapsed)

OpenLayers/Controls/SearchEngine.js, line 170

Collapse or display widget main container

Name Type Description
collapsed Boolean

True to collapse widget, False to display it

setMap(map)

OpenLayers/Controls/SearchEngine.js, line 147

Overwrite OpenLayers setMap method

Name Type Description
map ol.Map

Map.