Constructor
new Search(optionsopt)
Constructor
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The following properties are supported.
Properties
|
- Source:
Example
//for search response format (= just an empty array)
[
{
"value": "display value 1",
"data": {"type":"Feature","geometry":{"type":"Point","coordinates":[1187555.69,6019550.63]},"properties":{"lid":"layer0","fid":"fid0"}}
},
{
"value": "display value 2",
"data": {"type":"Feature","geometry":{"type":"Point","coordinates":[13555.69,6015650.63]},"properties":{"lid":"layer0","fid":"fid1"}}
},
{
"value": "display value n",
"data": {"type":"Feature","geometry":{"type":"Point","coordinates":[1087555.69,5419550.63]},"properties":{"lid":"layer1","fid":"fidn"}}
}
]
Members
_geoJsonFormat :ol.format.GeoJSON
Parser with the default geojson projection EPSG:4326
Type:
- ol.format.GeoJSON
- Source:
_mapEl :HTMLElement
Type:
- HTMLElement
- Source:
_searchOverlay :ol.layer.Vector
Type:
- ol.layer.Vector
- Source:
hoverStyle
The style to show a single search result on hover.
- Source:
layerSearchResults :ol.layer.Vector
Type:
- ol.layer.Vector
- Source:
limit
The number of potential hits (defaults value is 19).
- Source:
Example
//for setting a different search limit
Search.limit = 10;
limit :number
The number of maximum shown result items
Type:
- number
- Source:
map_ :ol.Map|null
Type:
- ol.Map | null
- Source:
MESSAGE_NOTHING_FOUND
The dfeault nothing found message for the search control. Can be overriden with an individual message.
- Source:
MESSAGE_PENDING
The dfeault nothing found message for the search control. Can be overriden with an individual message.
- Source:
minLength
The number af chars after which the search starts (Avoids unecessary traffic in the server). The default value is 3.
- Source:
Example
//for setting a different minLength
Search.minLength = 2;
onError :module:webgis4u/ol/control/Search~OnErrorCallback
Is called when an error occurs. Can be overriden by your own business logic.
Type:
- Source:
Example
Search.onError = (request, status, error, layer, map) => {
layer.getSource().clear();
if (status == "timeout") {
// timeout -> reload the page and try again
console.log("timeout");
} else {
// another error occured
console.log("error: " + request + status + err);
}
};
onHover :module:webgis4u/ol/control/Search~OnHoverCallback
Type:
- Source:
onSelect :module:webgis4u/ol/control/Search~OnSelectCallback
Type:
- Source:
Example
//Can be overridden with your code
Search.onSelect = (suggestion, layer, map, geoJsonFormat) => {
layer.getSource().clear();
layer.getSource().addFeature(feature);
zoomToExtent(feature.getGeometry().getExtent(), map);
};
onShow :module:webgis4u/ol/control/Search~OnShowCallback
Type:
- Source:
preprocessQuery
Preprocesses the query. It gets as input parameters the query string and the map and has to output a json array
- Source:
Example
// for setting a custom search response
Search.preprocessQuery = (query, map) => ({query, 'extent': map.getView().calculateExtent(map.getSize())});
searchFieldSelector :string
The selector for the search field
Type:
- string
- Source:
selectStyle
The style to show a selected search result.
- Source:
showStyle
The style to show all search results.
- Source:
timeout
The timout in ms for a search request (default = 2000).
- Source:
URL
The default search URL. Can be overridden with an individual value (defaults value is "/ugisSearch").
- Source:
Example
//for setting a different search URL
Search.url = "/myApplicationSpecificURL";
Methods
getSearchOverlay() → {ol.layer.Vector}
Gets the search overlay layer. Which is a vector layer on which the search result is visualized.
- Source:
Returns:
- Type
- ol.layer.Vector
Example
mySerachOverlayLayer = mySearchControl.getSearchOverlay();
getSearchResult() → {ol.layer.Vector}
Layer containing all search results
- Source:
Returns:
- Type
- ol.layer.Vector
Example
mySerachOverlayLayer = mySearchControl.getSearchResult();
getSuggestions() → {any}
- Source:
Returns:
The suggestions
- Type
- any
setMap(map)
Parameters:
Name | Type | Description |
---|---|---|
map |
ol.Map |
- Source: