OfflineSearchEngine
public class OfflineSearchEngine : SearchInterface
extension OfflineSearchEngine: NativeBase
extension OfflineSearchEngine: Hashable
The OfflineSearchEngine works without internet and unlocks the search and geocoding capabilities of HERE services to provide developers with unmatched flexibility to create differentiating location-enabled applications.
It provides the same interfaces as the SearchEngine, but the results may slightly differ as the results are taken from already downloaded map data instead of initiating a new request to a HERE backend service. This way the data may be, for example, older compared to the data you may receive when using the SearchEngine. On the other hand, this class provides results faster as no online connection is necessary.
In comparison to the SearchEngine, there are a few limitations:
- The IDs of POIs are different and may differ among different map versions.
- The implementation is different and the resources are limited, so the results can differ.
- OfflineSearchEngine sometimes doesn’t return the requested number of results.
Note: You can search only within persistent map data (downloaded via MapDownloader) or existing cached data.
However, cached data may be incomplete, which can result in searches returning partial or incomplete information.
Therefore, it is recommended to use persistent map data.
Make sure that at least LayerConfiguration.Feature.offlineSearch is enabled.
For EV rich attributes also enable LayerConfiguration.Feature.ev,
for truck rich attributes also enable LayerConfiguration.Feature.truckServiceAttributes,
for fuel station rich attributes also enable LayerConfiguration.Feature.fuelStationAttributes
in SDKOptions.layerConfiguration.
-
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init() throws -
Creates a new instance of this class.
Throws
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine) throwsParameters
sdkEngineInstance of an existing SDKEngine.
-
Performs an asynchronous text query search for
Placeinstances within a givenTextQuery.Area. The returned places are sorted by relevance.Declaration
Swift
@discardableResult public func searchByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryDesired free-form text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous address query search for
Placeinstances. This is the same type of search as forward geocoding, except that more data is returned than just the geographic coordinates of a given address. Note that an address can belong to more than onePlaceresult, although all found places will share the same geographic coordinates. The returned places are sorted by relevance.Declaration
Swift
@discardableResult public func searchByAddress(_ query: AddressQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryDesired free-form address query text to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous category search for
Placeinstances. A list containing at least onePlaceCategorymust be provided as part of thesearchByCategory(...).query.Declaration
Swift
@discardableResult public func searchByCategory(_ query: CategoryQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryQuery with list of desired categories.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous search for
Placeinstances based on the given geographic coordinates. This is the same search type as reverse geocoding, except that more data is returned than just theAddressrelated to the given coordinates. Note that more than onePlacecan be related to the given coordinates. The returned places are sorted by relevance.Declaration
Swift
@discardableResult public func searchByCoordinates(_ coordinates: GeoCoordinates, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
coordinatesThe coordinates where to search.
optionsSearch options.
completionCallback which receives result on the main thread.
Return Value
Handle that will be used to manipulate execution of the task.
-
Performs an asynchronous search for a
Placebased on its ID andLanguageCode.Declaration
Swift
@discardableResult public func searchByPlaceId(_ query: PlaceIdQuery, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandleParameters
queryThe id of place to search.
languageCodeThe preferred language for the search results. When unset or unsupported language is chosen, results will be returned in their local language.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous search for a
Placebased on the content found inPickedPlace. IfPickedPlacedata is obtained from the offline map, it may happen that the newer version that is used by the online service represented bySearchEngineno longer contains the related POI. In that case,SearchError.noResultsFounderror is reported. When that happens, you may try to obtain the POI from the offline map by callingOfflineSearchEngine.searchByPickedPlace, only available for the Navigate license.Declaration
Swift
@discardableResult public func searchByPickedPlace(_ pickedPlace: PickedPlace, languageCode: LanguageCode?, completion: @escaping PlaceIdSearchCompletionHandler) -> TaskHandleParameters
pickedPlaceThe content picked from map.
languageCodeThe preferred language for the search result. When unset or unsupported language is chosen, result will be returned in the local language.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous request to suggest places for text queries and returns suggestions sorted by relevance.
Note that while
OfflineSearchEngineincludes as many details as are available,SearchEngineincludes only the information that is relevant for autosuggest use cases. Complete details can be obtained by searching withPlaceIdQuery.Declaration
Swift
@discardableResult public func suggestByText(_ query: TextQuery, options: SearchOptions, completion: @escaping SuggestCompletionHandler) -> TaskHandleParameters
queryDesired text query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Attach data source into SearchEngine instance. Places from MyPlaces ranked the same way as places from default source. New data source replaces old one. Note: Only OfflineSearchEngine supports search over MyPlaces.
Declaration
Swift
public func attach(dataSource: MyPlaces, callback: @escaping TaskCompletionHandler) -> TaskHandleParameters
dataSourceThe data source.
callbackThe callback to be called when task is completed.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous request to search for places. The user submits a
StructuredQuerythat returns places adhering to the constraints provided inStructuredQuery. For example, when user wants results of type street for a text queryInvalidenstraßeinBerlin, it can be searched by preparingStructuredQueryprovidingStructuredQuery.queryasInvalidenstraße,StructuredQuery.areaCenter,StructuredQuery.AddressElements.countryasGermany,StructuredQuery.AddressElements.cityasBerlinandStructuredQuery.ResultTypeasSTREET. The results will be presented only from the given geographical area.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
Declaration
Swift
@discardableResult public func search(structQuery query: StructuredQuery, options: SearchOptions, completion: @escaping SearchCompletionHandler) -> TaskHandleParameters
queryDesired structured query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Performs an asynchronous request to suggest places for a
StructuredQuerybuilt with address elements and returns candidate suggestions sorted by relevance. For example, when user wants suggestions of type street for a text queryInvalidenstraßeinBerlin, it can be searched by preparingStructuredQueryprovidingStructuredQuery.queryasInvalidenstraße,StructuredQuery.areaCenter,StructuredQuery.AddressElements.countryasGermany,StructuredQuery.AddressElements.cityasBerlinandStructuredQuery.ResultTypeasSTREET. The suggestions will be presented only from the given geographical area.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
Declaration
Swift
@discardableResult public func suggest(structQuery query: StructuredQuery, options: SearchOptions, completion: @escaping SuggestCompletionHandler) -> TaskHandleParameters
queryDesired structured query to search.
optionsSearch options.
completionCallback which receives the result on the main thread.
Return Value
Handle that will be used to manipulate the execution of the task.
-
Enables or disables indexing. When indexing is enabled, HERE SDK will create a detailed index over persistent map data and update it as needed. A detailed index enables finding data faster and over entire persistent map. Creating an index takes time, but usually no more than a few seconds up to a couple of minutes, depending on persistent map size. As the feature is improved, the indexing time will improve. Also please note that this is a heavy processing task. The stored index increases the space taken by offline maps by around 2-5%. This may also improve in future versions.
Indexing is disabled by default. If you want it enabled, make sure to call setIndexOptions with
OfflineSearchIndex.Options.enabledastruebefore any operations inMapDownloaderorMapUpdaterthat modify the persistent map. Calling setIndexOptions may also create or remove map index to match the previously installed map regions. If the matching index for installed map regions is found, then indexing is skipped. While a new index is being created,OfflineSearchEnginefunctionality can still be used. However, without a valid index in place yet, it operates as though indexing is disabled. IfSDKNativeEngineis disposed during indexing (for example, by closing the app), the indexing is cancelled. RecreatingSDKNativeEngineand enabling indexing will ensure that index is created.Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
Declaration
Swift
public static func setIndexOptions(sdkEngine: SDKNativeEngine, options: OfflineSearchIndex.Options, listener: OfflineSearchIndexListener) -> OfflineSearchIndex.Error?Parameters
sdkEngineIndexing is enabled and disabled per SDKNativeEngine instance. The index is created inside the related
SDKOptions.persistentMapStoragePath.optionsSets indexing options.
listenerThe listener that will receive updates about indexing process. When
OfflineSearchIndex.Options.enabledis true, SDK would store listener and the listener will receive updates about indexing progress every time it is performed. WhenOfflineSearchIndex.Options.enabledis false, SDK would report indexing removal progress to the listener one last time and remove storage of listener.Return Value
An error in case there was one. It’s
nilif the indexing listener could be configured successfully.