Single Search addon control provides a single box for all search types.
Single Search Add-on
SingleSearch
Single Search Addon
new SingleSearch(options: Object)
Extends TrimbleMaps.Evented
Parameters
options
(Object)
Name | Type | Description |
---|---|---|
options.placeholderText |
string
(default: 'Address...' )
|
Placeholder text for the search box. |
options.doneTypingInterval |
number
(default: 700 )
|
The debounce value in milliseconds. The search web service request fire rate limit to this value. |
options.minSearchTextLength |
number
(default: 3 )
|
If search text is longer than this value, then search can be started. |
options.locationRelevance |
string
(default: null )
|
Available values are “mapCenter”, “device”, or null. If it is set, map view center or device location will be used to assist search. |
options.hideResults |
boolean
(default: false )
|
Hide results list or not when a result item is clicked on or enter key is pressed on a focused item. |
options.searchOption |
SearchOption
|
Optional. See the section below. |
options.markerStyle |
MarkerStyle
|
Optional. See the section below. |
options.markerConfig |
MarkerConfig
|
Optional. See the section below. |
options.popupConfig |
PopupConfig
|
Optional. See the section below. |
Instance Members
Sets a value for a property of the searchOption.
setSearchOption(key: ("query"
| "maxResults"
| "currentLonLat"
| "excludedSearchTypes"
| "poiCategories"
| "countries"
| "countryType"
| "states"
| "region"
| "success"
| "failure"
), value: any)
Parameters
key
(("query"
| "maxResults"
|
"currentLonLat"
| "excludedSearchTypes"
|
"poiCategories"
| "countries"
| "countryType"
|
"states"
| "region"
| "success"
|
"failure"
))
value
(any)
Sets a value for a property of the markerStyle.
setMarkerStyle(key: ("externalGraphic"
| "graphicHeight"
| "graphicWidth"
| "graphicXOffset"
| "graphicYOffset"
), value: any)
Parameters
key
(("externalGraphic"
| "graphicHeight"
|
"graphicWidth"
| "graphicXOffset"
|
"graphicYOffset"
))
value
(any)
Sets a value for a property of the markerConfig.
setMarkerConfig(key: ("exclusive"
| "centerOnMap"
| "zoomLevel"
), value: any)
Parameters
key
(("exclusive"
| "centerOnMap"
|
"zoomLevel"
))
value
(any)
Sets a value for a property of the popupConfig.
setPopupConfig(key: ("show"
| "className"
| "size"
| "offset"
| "closeBox"
), value: any)
Parameters
key
(("show"
| "className"
|
"size"
| "offset"
| "closeBox"
))
value
(any)
Remove the marker (and popup) from the map
removeMarker()
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options }).addTo(map);
// After a search has been performed and the marker is no longer needed
singleSearchControl.removeMarker();
Events
Fired when the input of the control gets focus.
inputfocus
Type: Object
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('inputfocus', function(){
console.log('Control input focused');
});
Fired when the input of the control loses focus.
inputblur
Type: Object
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('inputblur', function(){
console.log('Control input blurred');
});
Fired when a location is selected from the list.
locationselected
Type: Object
Properties
location
(Object)
: object that has the location information.
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('locationselected', function(evt){
console.log(evt.location);
});
Fired when a the search results are returned.
searchcomplete
Type: Object
Properties
locations
(Array)
: array of location information matching the search term.
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('searchcomplete', function(evt){
console.log(evt.locations);
});
Fired when the browser's geolocation call fails.
geolocationfailed
Type: Object
Properties
error
(Object)
: error returned from the browser.
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('geolocationfailed', function(evt){
console.log(evt.error);
});
Fired when the location popup closes.
popupClosed
Type: Object
Properties
popup
(Popup)
: the popup being closed.
Example
// Initialize the control
var singleSearchControl = new TrimbleMapsControl.SingleSearch({ // options });
// Listen for the event
singleSearchControl.on('popupClosed', function(evt){
console.log('Popup closed');
});
Types used in the options property of the add-on
Option Types
SearchOption
SearchOption
Type: Object
Properties
query
(string?)
: If it is not null, the search input box value will be ignored by the control. It is optional.
maxResults
(number?)
: Maximum returned results.
currentLonLat
(LngLat?)
: Search near the location provided. Latitude and longitude values are in degrees. It is optional. The
control can set current location based on navigator.geolocation location or map view center. They are
optional too.
excludedSearchTypes
(string?)
: Comma-separated list of types to exclude from the search.
poiCategories
(string?)
: Comma-separated list of POI category names by which you want to filter all POI results.
countries
(string?)
: Comma-separated list of country abbreviations by which you want to filter all results.
countryType
(("ISO"
| "FIPS"
|
"GENC2"
| "GENC3"
)?)
states
(string?)
: Comma-separated list of state abbreviations by which you want to filter all results.
region
((Common.Region.NA | Common.Region.EU | Common.Region.WW))
: Required.
success
(Function)
: If it is provided, it will replace the control built-in handler method.
failure
(Function)
: If it is provided, it will replace the control built-in handler method.
MarkerConfig
MarkerConfig
Type: Object
Properties
MarkerStyle
MarkerStyle
Type: Object
Properties
externalGraphic
(string?)
: If the URL is supplied, it will replace the default icon. If null, the control will choose icon for
the marker based on result type.
graphicHeight
(number?)
: Marker height in pixels.
graphicWidth
(number?)
: Marker width in pixels.
graphicXOffset
(number?)
: Marker x-direction offset.
graphicYOffset
(number?)
: Marker y-direction offset.
PopupConfig
PopupConfig
Type: Object