Guidesv3.2 API Referencev3.1 API Reference

Class: Service

Class: Service

Class: Service

H.service.xyz.Service

new H.service.xyz.Service (options) Deprecated : since 3.1.30.15

This class encapsulates the HERE Data Hub API in a service stub, providing methods to access its resources.

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

Name Type Description
options H.service.xyz.Service.Options

Configuration options for the service.

Throws:
Example
// Assumption: the platform is instantiated
var xyzService = platform.getXYZService({
  token: 'authentication_token_goes_here'
});

xyzService.getSpaces(console.log, console.error);

Extends

Members

H.service.xyz.Service.CONFIG_KEY string staticconstant

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 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

deleteFeatures (spaceId, params, onResult, onError)H.util.ICancelable

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

params H.service.ServiceParameters

Service parameters to be added to the request.

onResult function(H.service.ServiceResult)

A callback function to be called with an FeatureCollection object containing all the deleted features.

onError function(Error)

A callback function to be called in case of failed request.

Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

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.

getFeaturesByBoundingBox (spaceId, params, onResult, onError)H.util.ICancelable

To fetch all of the features found in the provided bounding box. See Data Hub API Reference - Get features in bounding box.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

params H.service.ServiceParameters

Service parameters to be added to the request.

onResult function(H.service.ServiceResult)

A callback function to be called with an object containing feature collection.

onError function(Error)

A callback function to be called in case of failed request.

Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

getFeaturesById (spaceId, params, onResult, onError)H.util.ICancelable

To fetch all of the features found for the provided list of ids. See Data Hub API Reference - Get features by ID.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

params H.service.ServiceParameters

Service parameters to be added to the request.

onResult function(H.service.ServiceResult)

A callback function to be called with an object containing feature collection.

onError function(Error)

A callback function to be called in case of failed request.

Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

getSpace (spaceId, onResult, onError)H.util.ICancelable

To retrieve a single space data. See Data Hub API Reference - Get a space by ID.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

onResult function(H.service.ServiceResult)

A callback function to be called with an object describing the "space" resource.

onError function(Error)

A callback function to be called in case of failed request.

Throws:

If at least one of params is not supplied.

Type
H.lang.InvalidArgumentError
Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

getSpaces (onResult, onError, opt_params)H.util.ICancelable

To retrieve spaces that are accessible with current authentication token. By default, only custom spaces are returned, not the common ones (e.g. "Chicago buildings"). It is possible to supply the owner service parameter to filter spaces by ownership, e.g. owner: "*" to retrieve all spaces the user has access to. See Data Hub API Reference - List spaces.

Name Type Description
onResult function(H.service.ServiceResult)

A callback function to be called with an array of spaces as an argument when request succeeds. Each space is represented as an object with the properties "id", "title", "description", "owner" and "cid".

onError function(Error)

A callback function to be called in case of failed request.

opt_params H.service.ServiceParameters optional

Optional service parameters.

Throws:

If at least one of params is not supplied.

Type
H.lang.InvalidArgumentError
Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

getStatistics (spaceId, onResult, onError)H.util.ICancelable

To retrieve a statistical information about the space. See Data Hub API Reference - Get statistics.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

onResult function(H.service.ServiceResult)

A callback function to be called with an object containing statistical information about the space.

onError function(Error)

A callback function to be called in case of failed request.

Throws:

If at least one of params is not supplied.

Type
H.lang.InvalidArgumentError
Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

This method returns the configured service URL.

Returns:
Type Description
H.service.Url

postFeatures (spaceId, geojsonObject, onResult, onError, opt_params)H.util.ICancelable

To create or patch features. See Data Hub API Reference - Modify features in the space

This method can be used for example for adding new features to the space or adding additional properties to the existing features.

Use H.service.xyz.Service#putFeatures to add/replace features or their properties.

See H.map.Object#toGeoJSON to obtain the GeoJSON representation of a map object.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

geojsonObject Object

A GeoJSON object (FeatureCollection or Feature) to add/patch in the space.

onResult function(H.service.ServiceResult)

A callback function to be called with an FeatureCollection object containing all the modified features.

onError function(Error)

A callback function to be called in case of failed request.

opt_params H.service.ServiceParameters optional

Service parameters to be added to the request.

Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

putFeatures (spaceId, geojsonObject, onResult, onError, opt_params)H.util.ICancelable

To create or replace the provided features. See Data Hub API Reference - Create or replace multiple features

This method can be used for example for adding new features to the space or replacing properties of the existing features.

Use H.service.xyz.Service#postFeatures to patch the features or their properties.

See H.map.Object#toGeoJSON to obtain the GeoJSON representation of a map object.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

geojsonObject Object

A GeoJSON object (FeatureCollection or Feature) to add/replace in the space.

onResult function(H.service.ServiceResult)

A callback function to be called with an object containing a FeatureCollection containing all modified features.

onError function(Error)

A callback function to be called in case of failed request.

opt_params H.service.ServiceParameters optional

Service parameters to be added to the request.

Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

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

To search for features in the space. See Data Hub API Reference - Search for features.

Name Type Description
spaceId string

Space ID that defines a given "space" resource.

onResult function(H.service.ServiceResult)

A callback function to be called with an object containing feature collection.

onError function(Error)

A callback function to be called in case of failed request.

opt_params H.service.ServiceParameters optional

Service parameters to be added to the request.

Throws:

If at least one of required params is not supplied.

Type
H.lang.InvalidArgumentError
Returns:
Type Description
H.util.ICancelable A handle that allows to cancel the request.

Type Definitions

H.service.xyz.Service.Options Object

This type encapsulates configuration options for an instance of a XYZ service.

Properties:
Name Type Argument Description
token string

The authentication token. Can be generated by Data Hub Console.

baseUrl H.service.Url <optional>

The base URL of the service. If supplied, it overrides all defaults (either coming from platform or service internals) including authentication params.

subDomain string <optional>

The subdomain of the XYZ service relative to the base URL.

path string <optional>

The path to use within the service URL.

headers Object <optional>

A map of HTTP headers to be sent with each request made by the service.