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:
-
-
If
"token"is not supplied in options.
-
-
-
If instantiated directly.
-
Example
// Assumption: the platform is instantiated
var xyzService = platform.getXYZService({
token: 'authentication_token_goes_here'
});
xyzService.getSpaces(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
-
deleteFeatures (spaceId, params, onResult, onError)H.util.ICancelable
-
To delete multiple features. See Data Hub API Reference - Delete multiple features from the space
Name Type Description spaceIdstring Space ID that defines a given "space" resource.
paramsH.service.ServiceParameters Service parameters to be added to the request.
onResultfunction(H.service.ServiceResult) A callback function to be called with an FeatureCollection object containing all the deleted features.
onErrorfunction(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
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. -
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 spaceIdstring Space ID that defines a given "space" resource.
paramsH.service.ServiceParameters Service parameters to be added to the request.
onResultfunction(H.service.ServiceResult) A callback function to be called with an object containing feature collection.
onErrorfunction(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 spaceIdstring Space ID that defines a given "space" resource.
paramsH.service.ServiceParameters Service parameters to be added to the request.
onResultfunction(H.service.ServiceResult) A callback function to be called with an object containing feature collection.
onErrorfunction(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 spaceIdstring Space ID that defines a given "space" resource.
onResultfunction(H.service.ServiceResult) A callback function to be called with an object describing the "space" resource.
onErrorfunction(Error) A callback function to be called in case of failed request.
Throws:
-
If at least one of params is not supplied.
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
ownerservice 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 onResultfunction(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".onErrorfunction(Error) A callback function to be called in case of failed request.
opt_paramsH.service.ServiceParameters optional Optional service parameters.
Throws:
-
If at least one of params is not supplied.
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 spaceIdstring Space ID that defines a given "space" resource.
onResultfunction(H.service.ServiceResult) A callback function to be called with an object containing statistical information about the space.
onErrorfunction(Error) A callback function to be called in case of failed request.
Throws:
-
If at least one of params is not supplied.
Returns:
Type Description H.util.ICancelable A handle that allows to cancel the request. -
-
getUrl ()H.service.Url inherited
-
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#putFeaturesto add/replace features or their properties.See
H.map.Object#toGeoJSONto obtain the GeoJSON representation of a map object.Name Type Description spaceIdstring Space ID that defines a given "space" resource.
geojsonObjectObject A GeoJSON object (
FeatureCollectionorFeature) to add/patch in the space.onResultfunction(H.service.ServiceResult) A callback function to be called with an FeatureCollection object containing all the modified features.
onErrorfunction(Error) A callback function to be called in case of failed request.
opt_paramsH.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#postFeaturesto patch the features or their properties.See
H.map.Object#toGeoJSONto obtain the GeoJSON representation of a map object.Name Type Description spaceIdstring Space ID that defines a given "space" resource.
geojsonObjectObject A GeoJSON object (
FeatureCollectionorFeature) to add/replace in the space.onResultfunction(H.service.ServiceResult) A callback function to be called with an object containing a FeatureCollection containing all modified features.
onErrorfunction(Error) A callback function to be called in case of failed request.
opt_paramsH.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
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
-
search (spaceId, onResult, onError, opt_params)H.util.ICancelable
-
To search for features in the space. See Data Hub API Reference - Search for features.
Name Type Description spaceIdstring Space ID that defines a given "space" resource.
onResultfunction(H.service.ServiceResult) A callback function to be called with an object containing feature collection.
onErrorfunction(Error) A callback function to be called in case of failed request.
opt_paramsH.service.ServiceParameters optional Service parameters to be added to the request.
Throws:
-
If at least one of required params is not supplied.
Returns:
Type Description H.util.ICancelable A handle that allows to cancel the request. -
Type Definitions
-
This type encapsulates configuration options for an instance of a XYZ service.
Properties:
Name Type Argument Description tokenstring The authentication token. Can be generated by Data Hub Console.
baseUrlH.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.
subDomainstring <optional>
The subdomain of the XYZ service relative to the base URL.
pathstring <optional>
The path to use within the service URL.
headersObject <optional>
A map of HTTP headers to be sent with each request made by the service.