This class encapsulates the Geocoding and Search API as a service stub.
It's not allowed to call the constructor directly (an IllegalOperationError is thrown).
Instead an instance of this Service can be retrieved by calling the factory method
H.service.Platform#getSearchService on a platform instance.
| Name | Type | Description |
|---|---|---|
opt_options |
H.service.Options |
optional
Configuration options for the Search service |
Throws:
-
-
in case of invalid specified options
-
-
-
when trying to create an instance using constructor
-
Example
// Assumption: the platform is instantiated
const service = platform.getSearchService();
service.geocode({
'q': '5 Rue Daunou, 75000 Paris, France'
}, console.log, console.error);
Extends
Members
-
The property name to use when specifying options for this service within the
H.service.Platform.Options#servicesConfig.
Methods
-
addEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method adds a listener for a specific event.
Note that to prevent potential memory leaks, you must either call
removeEventListenerordisposeon the given object when you no longer need it.Name Type Description typestring The name of the event
handlerfunction An event handler function
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject optional An object defining the scope for the handler function
-
addOnDisposeCallback (callback, opt_scope) inherited
-
This method adds a callback which is triggered when the
EventTargetobject is being disposed.Name Type Description callbackfunction The callback function.
opt_scopeObject optional An optional scope for the callback function
-
autocomplete (params, onResult, onError)H.util.ICancelable
-
This method provides possible complete addresses by matching the input text terms to parts of an address. Geocoding and Search API.
Please refer to the
/autocompleteendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().autocomplete({ q: 'Pariser 2 Frank', limit: 3 }, console.log, console.error) -
autosuggest (params, onResult, onError)H.util.ICancelable
-
This method improves the user's search experience by allowing submittal of free-form, incomplete and misspelled addresses or place names to the endpoint of the Geocoding and Search API.
Please refer to the
/autosuggestendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().autosuggest({ at: '52.5199813,13.3985138', limit: 5, q: 'res' }, console.log, console.error) -
browse (params, onResult, onError)H.util.ICancelable
-
This method uses the
/browseendpoint of the Geocoding and Search API and returns a structured search result by filtering items by category and name at a given geo-position in a radius of 250km. Items returned are places, streets or localities, ranked by increasing distance.Please refer to the
/browseendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().browse({ at: '-23.000813,-43.351629', limit: 2, categories: '100-1100,200-2000-0011,100-1000' }, console.log, console.error) -
discover (params, onResult, onError)H.util.ICancelable
-
This method simplifies searching for places. The user submits a free-form text request that returns candidate items (places and addresses related) in the order of intent matching relevance.
Please refer to the
/discoverendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().discover({ at: '42.36399,-71.05493', limit: 1, q: 'restaurant', in: 'countryCode:USA' }, console.log, console.error) -
dispatchEvent (evt) inherited
-
This method dispatches an event on the
EventTargetobject.Name Type Description evtH.util.Event | string An object representing the event or a string with the event name
-
dispose () inherited
-
This method removes listeners from the given object. Classes that extend
EventTargetmay need to override this method in order to remove references to DOM Elements and additional listeners. -
geocode (params, onResult, onError)H.util.ICancelable
-
This method can be used to find the geographic coordinates of a known address, place, locality or administrative area, even if the query is incomplete or partly incorrect. It also returns a complete postal address string and address details. It sends a geocoding request to the
/geocodeendpoint of the Geocoding and Search API.Please refer to the
/geocodeendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().geocode({ q: '5 Rue Daunou, 75000 Paris, France' }, console.log, console.error) -
getUrl ()H.service.Url inherited
-
This method returns the configured service URL.
Returns:
Type Description H.service.Url -
lookup (params, onResult, onError)H.util.ICancelable
-
Every place or location object known by HERE has a location identifier or "ID". This method sends a lookup request by
IDto the/lookupendpoint of the Geocoding and Search API.Please refer to the
/lookupendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().lookup({ id: 'here:pds:place:276u0vhj-b0bace6448ae4b0fbc1d5e323998a7d2' }, console.log, console.error) -
removeEventListener (type, handler, opt_capture, opt_scope) inherited
-
This method removes a previously added listener from the
EventTargetinstance.Name Type Description typestring The name of the event
handlerfunction A previously added event handler
opt_captureboolean optional trueindicates that the method should listen in the capture phase (bubble otherwise)opt_scopeObject optional An object defining the scope for the handler function
-
reverseGeocode (params, onResult, onError)H.util.ICancelable
-
This method can be used to find the nearest address to specific geographic coordinates. It sends a reverse geocoding request to the
/revgeocodeendpoint of the Geocoding and Search API.Please refer to the
/revgeocodeendpoint documentation for information on available parameters and the response object structure.Name Type Description paramsH.service.ServiceParameters Contains service parameters to be sent with the request.
onResultfunction(H.service.ServiceResult) A callback function to be called once the API provides a response to the request.
onErrorfunction(Error) A callback function to be called if a communication error occurs during the request.
Returns:
Type Description H.util.ICancelable a handle that allows to cancel the request. Example
platform.getSearchService().reverseGeocode({ at: '48.2181679,16.3899064' }, console.log, console.error)