Maps API for JavaScript Developer's Guide

H.service.Platform

Class Summary

Platform is a central class from which all other service stubs are created. It contains the shared settings to be passed to the individual service stubs, for example the root URL of the platform, application credentials, etc.

[ For full details, see the Class Details ]

Method Summary

Table 1. Methods
Methods

setBaseUrl (baseUrl)

To set the base URL to be used when creating service stubs.

getBaseUrl () : {H.service.Url}

To obtain the currently used base URL.

createService (Service, opt_options) : {Object}

This method creates an instance of a given service class, configured with options that are based on defaults and supplied overrides.

getOMVService (opt_options) : {H.service.omv.Service}

To create a new instance of H.service.omv.Service to query data from the HERE Optimized Map Visualization (OMV) endpoint.

getMapTileService (opt_options) : {H.service.MapTileService}

To create a new instance of H.service.MapTileService to query the Map Tile API.

createDefaultLayers (opt_tileSize, opt_ppi, opt_lang, opt_secondaryLang, opt_style, opt_pois) : {H.service.DefaultLayers}

This method creates a pre-configured set of HERE layers for convenient use with the map. It returns an object with the following sections:

getRoutingService (opt_options) : {H.service.RoutingService}

To create a new instance of H.service.RoutingService to query the Routing API.

getGeocodingService (opt_options) : {H.service.GeocodingService}

To create a new instance of H.service.GeocodingService to query the Geocoder API.

getPlacesService (opt_options) : {H.service.PlacesService}

To create a new instance of H.service.PlacesService to query the Places API.

getTrafficService (opt_options) : {H.service.traffic.Service}

This method returns an instance of H.service.traffic.Service to query the Traffic API Traffic Incident Data

getPlatformDataService (opt_options) : {H.service.extension.platformData.Service}

This method returns an instance of H.service.extension.platformData.Service to query the Platform Data Extension API.

getGeofencingService (opt_options) : {H.service.extension.geofencing.Service}

Returns a new instance of H.service.extension.geofencing.Service to query the Geofencing Extension API.

getCustomLocationService (opt_options) : {H.service.extension.customLocation.Service}

To obtain a new instance of H.service.extension.customLocation.Service to query the CLE API.

getCustomRoutingService (opt_options) : {H.service.extension.customRoute.Service}

Returns a new instance of H.service.extension.customRoute.Service to query the Custom Route Extension API.

Class Description

Platform is a central class from which all other service stubs are created. It contains the shared settings to be passed to the individual service stubs, for example the root URL of the platform, application credentials, etc.

Example

var platform = new H.service.Platform({
  apikey: [your apikey],     // set your apikey
});

var geocoder = platform.getGeocodingService();
// Now you are ready to talk to the HERE Geocoder API

// It's also possible to re-configure a set of services in one go,
// passing their options combined in the "servicesConfig".
// Keys of that dictionary should be taken from "CONFIG_KEY" of corresponding services.
var servicesConfig = {};
servicesConfig[H.service.GeocodingService.CONFIG_KEY] = {
  // all defaults are replaced by "baseUrl" if it's specified
  baseUrl: new H.service.Url('https', 'custom.geocoder.example.org')
};
servicesConfig[H.service.RoutingService.CONFIG_KEY] = {
  subDomain: 'routing',
  path: 'custom/path'
};

var customPlatform = new H.service.Platform({
  apikey: [your apikey]
});
var customGeocoder = customPlatform.getGeocodingService();
var customRouting = customPlatform.getRoutingService();

Constructor Details

H.service.Platform(options)

Parameters:
 
options:
{H.service.Platform.Options}
 
Contains configuration options

Method Details

setBaseUrl (baseUrl)

To set the base URL to be used when creating service stubs.

Parameters:
 
baseUrl:
{H.service.Url}
 
The new base URL to use

getBaseUrl () : {H.service.Url}

To obtain the currently used base URL.

Returns:
 
{H.service.Url}
The current base URL

createService (Service, opt_options) : {Object}

This method creates an instance of a given service class, configured with options that are based on defaults and supplied overrides.

Parameters:
 
Service:
{function(Object)}
 
The constructor of the service to instantiate
opt_options:
{Object}
 
Contains configuration options for a given service
Returns:
 
{Object}
An service instance

getOMVService (opt_options) : {H.service.omv.Service}

To create a new instance of H.service.omv.Service to query data from the HERE Optimized Map Visualization (OMV) endpoint.

Parameters:
 
opt_options:
{H.service.omv.Service.Options=} [optional]
 
Configuration options for OMV service
Returns:
 
{H.service.omv.Service}
The created OMV service instance

getMapTileService (opt_options) : {H.service.MapTileService}

To create a new instance of H.service.MapTileService to query the Map Tile API.

Parameters:
 
opt_options:
{H.service.MapTileService.Options=} [optional]
 
Configuration options for map tile service
Returns:
 
{H.service.MapTileService}
The created map tile service instance

createDefaultLayers (opt_tileSize, opt_ppi, opt_lang, opt_secondaryLang, opt_style, opt_pois) : {H.service.DefaultLayers}

This method creates a pre-configured set of HERE layers for convenient use with the map. It returns an object with the following sections:

Example

// Create the default layers
var layers = platform.createDefaultLayers({pois: true});

// Add traffic overlay to the map
map.addLayer(layers.vector.normal.traffic);
Parameters:
 
opt_tileSize:
{(H.service.Platform.DefaultLayersOptions | number)=} [optional]
 
If this parameter is a number, it indicates the tile size to be queried from the HERE Map Tile API (the default value is 256); if this parameter is an object, it represents configuration options for the layer and all the remaining parameters (below) should be omitted
opt_ppi:
{number=} [optional]
 
An optional 'ppi' parameter to use when querying tiles, see Base Map Tile – Optional Query Parameters for more details.
opt_lang:
{string=} [optional]
 
An identifier of the primary language parameter, the default is not specified
opt_secondaryLang:
{string=} [optional]
 
An identifier of the secondary language parameter, the default is not specified
opt_style:
{string=} [optional]
 
An optional 'style' parameter to use when querying map tiles, the default is not specified
opt_pois:
{(string | boolean)=} [optional]
 
A Boolean value indicating if POIs are displayed on the map (true) or a mask for the POI Categories as described in the Map Tile API documentation POI Categories. By default POIs are disabled.
Returns:
 
{H.service.DefaultLayers}
a set of layers ready to use

getRoutingService (opt_options) : {H.service.RoutingService}

To create a new instance of H.service.RoutingService to query the Routing API.

Parameters:
 
opt_options:
{H.service.RoutingService.Options=} [optional]
 
Configuration options for routing service
Returns:
 
{H.service.RoutingService}
The created RoutingService instance

getGeocodingService (opt_options) : {H.service.GeocodingService}

To create a new instance of H.service.GeocodingService to query the Geocoder API.

Parameters:
 
opt_options:
{H.service.GeocodingService.Options=} [optional]
 
Configuration options for geocoding service
Returns:
 
{H.service.GeocodingService}
The created GeocodingService instance

getPlacesService (opt_options) : {H.service.PlacesService}

To create a new instance of H.service.PlacesService to query the Places API.

Parameters:
 
opt_options:
{H.service.omv.Service.Options=} [optional]
 
Configuration options for places service
Returns:
 
{H.service.PlacesService}
The created PlacesService instance

getTrafficService (opt_options) : {H.service.traffic.Service}

This method returns an instance of H.service.traffic.Service to query the Traffic API Traffic Incident Data

Parameters:
 
opt_options:
{H.service.traffic.Service.Options=} [optional]
 
Configuration options for traffic service
Returns:
 
{H.service.traffic.Service}
The created traffic service instance

getPlatformDataService (opt_options) : {H.service.extension.platformData.Service}

This method returns an instance of H.service.extension.platformData.Service to query the Platform Data Extension API.

Parameters:
 
opt_options:
{H.service.extension.platformData.Service.Options=} [optional]
 
Configuration options for PDE service
Returns:
 
{H.service.extension.platformData.Service}
The created PDE service instance

getGeofencingService (opt_options) : {H.service.extension.geofencing.Service}

Returns a new instance of H.service.extension.geofencing.Service to query the Geofencing Extension API.

Parameters:
 
opt_options:
{H.service.extension.geofencing.Service.Options=} [optional]
 
Configuration options for geofencing service
Returns:
 
{H.service.extension.geofencing.Service}
The created geofencing service instance

getCustomLocationService (opt_options) : {H.service.extension.customLocation.Service}

To obtain a new instance of H.service.extension.customLocation.Service to query the CLE API.

Parameters:
 
opt_options:
{H.service.extension.customLocation.Service.Options=} [optional]
 
Configuration options for CLE service
Returns:
 
{H.service.extension.customLocation.Service}
The created CLE service instance

getCustomRoutingService (opt_options) : {H.service.extension.customRoute.Service}

Returns a new instance of H.service.extension.customRoute.Service to query the Custom Route Extension API.

Parameters:
 
opt_options:
{H.service.extension.customRoute.Service.Options=} [optional]
 
Configuration options for custom route service
Returns:
 
{H.service.extension.customRoute.Service}
The created custom routing service instance