Class: PlacesService

H.service.PlacesService

new H.service.PlacesService (opt_options) Deprecated : since 3.1.14.0

This service is no longer being actively developed. The H.service.SearchService could be used instead.

This service implements a low-level Places REST API access. Please refer to Restful API documentation for providing parameters and handling response objects.

Entry point parameters are specified as key:value pairs which are transformed into URL parameters. Request headers can be specified along with entry point parameters.

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#getPlacesService on a platform instance.

Name Type Description
opt_options H.service.Options optional

Configuration options for places service

Throws:
Example
// Assumption: platform is instantiated
platform.getPlacesService().search({
  'at': '52.5044,13.3909',
  'q': 'pizza',
  'Accept-Language': 'de'
}, console.log, console.error);

Extends

Members

H.service.PlacesService.CONFIG_KEY string staticconstant

The property name to use when specifying options for this service within the H.service.Platform.Options#servicesConfig.

H.service.PlacesService.EntryPoint string static

This object contains a list of available entry points.

Properties:
Name Description
SEARCH
SUGGEST
EXPLORE
AROUND
HERE
CATEGORIES

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 removeEventListener or dispose on the given object when you no longer need it.

Name Type Description
type string

The name of the event

handler function

An event handler function

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object 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 EventTarget object is being disposed.

Name Type Description
callback function

The callback function.

opt_scope Object optional

An optional scope for the callback function

around (aroundParams, onResult, onError)H.util.ICancelable

This method triggers the Places API 'around' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
aroundParams H.service.ServiceParameters

Contains Places API 'around' entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle

categories (categoriesParams, onResult, onError)H.util.ICancelable

This method triggers the Places API 'categories' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
categoriesParams H.service.ServiceParameters

Contains Places API 'categories' entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle

dispatchEvent (evt) inherited

This method dispatches an event on the EventTarget object.

Name Type Description
evt H.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 EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.

explore (exploreParams, onResult, onError)H.util.ICancelable

This method triggers the Places API 'explore' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
exploreParams H.service.ServiceParameters

Contains Places API 'explore' entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle

follow (hyperlink, onResult, onError, opt_additionalParameters)H.util.ICancelable

This method is used to follow hyperlinks in the results returned by discovery queries.

Name Type Description
hyperlink string

A string containing a hyperlink to follow

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

opt_additionalParameters Object optional

Contains additional parameters to send with the request

Returns:
Type Description
H.util.ICancelable A request handle
Example
// Assumption: the platform is instantiated
var places = platform.getPlacesService();
places.request(
  H.service.PlacesService.EntryPoint.SEARCH,
  {
    'at': '52.5044,13.3909',
    'q': 'pizza'
  }, (response) => {
    places.follow(response.results.items[0].href, console.log, console.error);
  }, console.error);

This method returns the configured service URL.

Returns:
Type Description
H.service.Url

here (hereParams, onResult, onError)H.util.ICancelable

This method triggers the Places API 'here' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
hereParams H.service.ServiceParameters

Contains Places API 'here' entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle

removeEventListener (type, handler, opt_capture, opt_scope) inherited

This method removes a previously added listener from the EventTarget instance.

Name Type Description
type string

The name of the event

handler function

A previously added event handler

opt_capture boolean optional

true indicates that the method should listen in the capture phase (bubble otherwise)

opt_scope Object optional

An object defining the scope for the handler function

request (entryPoint, entryPointParams, onResult, onError)H.util.ICancelable

This method implements a generic means of querying the Places REST API.

Name Type Description
entryPoint string

An identifier indicating one of the available entry points (H.service.PlacesService.EntryPoint), for example, H.service.PlacesService.EntryPoint.SEARCH

entryPointParams Object

Contains map key value pairs to be transformed into the URL parameters. For entry point parameters description, please refer to Places RESTful API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs (for example request timeout)

Returns:
Type Description
H.util.ICancelable A request handle
Example
// Assumption: the platform is instantiated
platform.getPlacesService().request(
  H.service.PlacesService.EntryPoint.SEARCH,
  {'at': '52.5044,13.3909', 'q': 'pizza'},
  console.log,
  console.error);

This method triggers the Places API 'search' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
searchParams H.service.ServiceParameters

Contains Places API search entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle

suggest (suggestParams, onResult, onError)H.util.ICancelable

This method triggers the Places API 'suggestions' entry point. Please refer to documentation for parameter specification and response handling.

Name Type Description
suggestParams H.service.ServiceParameters

Contains Places API 'suggest' entry point parameters, please refer to Places API documentation

onResult function(H.service.ServiceResult)

A callback which is called when result is available

onError function(Error)

A callback which is called when an error occurs

Returns:
Type Description
H.util.ICancelable A request handle