The viv.location
library provides:
location:Autocomplete
macro that creates an auto-complete Views component that presents real-time completion suggestions for contacts and nearby locations (named points).Autosuggest
action invoked by the Autocomplete
macro.Input | Type | Notes |
---|---|---|
searchTerm | SearchTerm | Required |
isFuzzyMatchAddressType | boolean | true: use fuzzy matching for Geo addresses |
isSearchGeoLocations | boolean | true: search geo locations |
There are matching primitive concepts for each of the Autosuggest
inputs.
Concept | Type | Description |
---|---|---|
SearchTerm | text | term used to search for contacts or locations |
IsFuzzyMatchAddressType | boolean | true: use fuzzy matching for Geo addresses |
IsSearchGeoLocations | boolean | true: search geo locations |
The viv.location
library imports viv.geo
.
Accessing the user's contacts requires the contacts
library permission from bixby.contact
. Read bixby.contact
documentation for more details. If this permission is not granted, Autosuggest
can still autocomplete named locations.
The recommended way to use the auto-complete functionality of viv.location
is to use the provided location:Autocomplete
macro.
input-view {
match: DestinationPoint
message ("Where would you like to go?")
render {
macro (location:Autocomplete) {
param (noResultText) {
dialog-template ("No results")
}
param (placeholder) {
dialog-template ("Search for locations")
}
param (searchResultsLabel) {
dialog-template ("Search Results")
}
select-button-text {
template ("Ok")
}
}
}
}
The macro takes three text parameters:
noResultText
: displayed when there are no possible results for the completion as entered by the user. The default is "No results".placeholder
: The placeholder text used for the auto-complete field. The default is "Search for locations".searchResultsLabel
: The label used as a title for the search results. The default is "Search Results".While it is recommended that you use the macro, you can create your own auto-complete
component that uses the Autosuggest
action. The macro creates one similar to the following:
...
auto-complete {
type (geo.NamedPoint)
no-result-text { template ("No results") }
placeholder { template ("Search for locations") }
source {
collect-with (query) {
intent {
goal: Autosuggest
value: SearchTerm$expr (query)
value: IsFuzzyMatchAddressType (true)
}
}
label { template ("Search Results") }
where-each (place) {
display {
primary-text { template ("[#{value(place.name)}]") }
secondary-text { template ("[#{value(place.address)}]") }
}
on-select {
intent {
goal: geo.NamedPoint
value: viv.core.FormElement (place)
}
}
}
permissions {
library-permission (contact:contacts)
library-permission (self:profile)
}
}
}
...
By default, the Autosuggest
action will use location data to help resolve suggestions. You can disable this by setting IsSearchGeoLocations
to false
in the intent
block:
intent {
goal: location.Autosuggest
value: location.SearchTerm$expr (query)
value: location.IsSearchGeoLocations (false)
}
If you disable isSearchGeoLocations
, then Autosuggest
will not be able to autocomplete locations.
Setting IsFuzzyMatchAddressType
to true
will allow "fuzzy matching" for address types such as home
and office
. This is set to true
by the location:Autocomplete
macro, but it defaults to false
.