Class: Platform

H.service.Platform

new H.service.Platform (options)

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.

Name Type Description
options H.service.Platform.Options

Contains configuration options

Throws:
Example
var platform = new H.service.Platform({
  apikey: '{YOUR_API_KEY}', // 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" option.
// Keys of that dictionary should be taken from "CONFIG_KEY" of corresponding services.
var customPlatform = new H.service.Platform({
  apikey: '{YOUR_API_KEY}',
  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')
    },

    [H.service.RoutingService.CONFIG_KEY]: {
      subDomain: 'routing',
      path: 'custom/path'
    }
  }
});
var customGeocoder = customPlatform.getGeocodingService();
var customRouting = customPlatform.getRoutingService();

Methods

createDefaultLayers (opt_tileSize, opt_ppi, opt_lang, opt_secondaryLang, opt_style, opt_pois)Object

This method creates a pre-configured set of HERE layers for convenient use with the map. More details about the used map content services can be found at:

Name Type Description
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 v2" or "HERE Raster Tile API v3" (the default value is 512); 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, the default is not specified. See Base Map Tile – Optional Query Parameters for more details. For layers with raster tiles from HERE Raster Tile API v3 a value > 72 means, that tiles designed for 200 ppi are used, otherwise 100 ppi.

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), valid for the "HERE Vector Tile API", "HERE Map Tile API v2" and "HERE Raster Tile API v3". For layers from HERE Map Tile API v2, a string for the POI Categories can be provided as described in the documentation for POI Categories. By default POIs are disabled.

Returns:
Type Description
Object An object with the set of layers. The set of layers depends on engineType property of H.service.Platform.DefaultLayersOptions.

Please note that the following layers provide additional premium content like vehicle restrictions and additional POI categories to support the transportation and logistics use case:
  • vector.normal.logistics
  • vector.normal.logisticsnight
  • hybrid.logistics.vector
  • hybrid.logisticsnight.vector
This premium content is classified as transactions under the 'Advanced Vector Tile' category in the HERE Map Rendering system.
For more details on premium content and pricing, please refer to HERE Vector Tile API - Advanced layers

Please note that the layer vector.normal.truck is deprecated and will stop working in future.
Please switch to the HARP engine (see Migrate to the HARP engine) and make use of the logistics base map style and the feature & modes capabilities.
Layer Type Description Supported by H.Map.EngineType
vector.normal.map H.map.layer.TileLayer Map with all features and labels HARP, WEBGL
vector.normal.mapnight H.map.layer.TileLayer Map in night mode with all features and labels HARP
vector.normal.lite H.map.layer.TileLayer Reduced map with all features and labels HARP
vector.normal.litenight H.map.layer.TileLayer Reduced map in night mode with all features and labels HARP
vector.normal.roadnetwork H.map.layer.TileLayer Road network map HARP
vector.normal.roadnetworknight H.map.layer.TileLayer Road network map in night mode HARP
vector.normal.truck H.map.layer.TileLayer Map with all features and labels plus truck information (deprecated) WEBGL
vector.normal.traffic H.map.layer.TileLayer Transparent map with traffic flow information (deprecated) WEBGL
vector.normal.trafficincidents H.map.layer.MarkerTileLayer Transparent map with traffic incidents markers (deprecated) HARP, WEBGL
vector.normal.logistics H.map.layer.TileLayer Map style tailored for route planning, navigation, and logistics operations HARP
vector.normal.logisticsnight H.map.layer.TileLayer Map style tailored for route planning, navigation, and logistics operations in night mode HARP
vector.normal.topo H.map.layer.TileLayer Topographic map with hill shading and contours HARP
vector.normal.toponight H.map.layer.TileLayer Topographic map with hill shading and contours in night mode HARP
vector.traffic.map H.map.layer.TileLayer Overlay with traffic flow and incidents markers HARP, WEBGL
vector.traffic.mapnight H.map.layer.TileLayer Overlay with traffic flow and incidents markers adapted to the map in night mode HARP
vector.traffic.lite H.map.layer.TileLayer Overlay with traffic flow and incidents markers adapted to the reduced map HARP
vector.traffic.litenight H.map.layer.TileLayer Overlay with traffic flow and incidents markers adapted to the reduced map in night mode HARP
vector.traffic.logistics H.map.layer.TileLayer Overlay with traffic flow and incidents markers compatible with the logistics map HARP
vector.traffic.topo H.map.layer.TileLayer Overlay with traffic flow and incidents markers compatible with the topographic map HARP
vector.traffic.toponight H.map.layer.TileLayer Overlay with traffic flow and incidents markers compatible with the topographic map in night mode HARP
raster.normal.map H.map.layer.TileLayer Map with all features and labels HARP, WEBGL, P2D
raster.normal.mapnight H.map.layer.TileLayer Map in night mode with all features and labels HARP, WEBGL, P2D
raster.normal.xbase H.map.layer.TileLayer Map without features and labels HARP, WEBGL, P2D
raster.normal.xbasenight H.map.layer.TileLayer Map in night mode without features and labels HARP, WEBGL, P2D
raster.normal.base H.map.layer.TileLayer Map without labels HARP, WEBGL, P2D
raster.normal.basenight H.map.layer.TileLayer Map in night mode without labels HARP, WEBGL, P2D
raster.normal.trafficincidents H.map.layer.MarkerTileLayer Transparent map with traffic incidents markers (deprecated) HARP, WEBGL, P2D
raster.normal.transit H.map.layer.TileLayer Map with public transport lines (deprecated) HARP, WEBGL, P2D
raster.normal.labels H.map.layer.TileLayer Transparent map with labels only HARP, WEBGL, P2D
raster.normal.metaInfo H.map.layer.TileLayer Metadata information about raster tiles P2D
raster.satellite.map H.map.layer.TileLayer Satellite map with all features and labels HARP, WEBGL, P2D
raster.satellite.xbase H.map.layer.TileLayer Satellite map without features and labels HARP, WEBGL, P2D
raster.satellite.base H.map.layer.TileLayer Satellite map without labels HARP, WEBGL, P2D
raster.satellite.labels H.map.layer.TileLayer Transparent map tiles with labels only HARP, WEBGL, P2D
raster.terrain.map H.map.layer.TileLayer Terrain map with all features and labels (deprecated with WEBGL and P2D) HARP, WEBGL, P2D
raster.terrain.xbase H.map.layer.TileLayer Terrain map without features and labels (deprecated) HARP, WEBGL, P2D
raster.terrain.base H.map.layer.TileLayer Terrain map without labels (deprecated with WEBGL and P2D) HARP, WEBGL, P2D
raster.terrain.labels H.map.layer.TileLayer Transparent map tiles with labels only (deprecated with WEBGL and P2D) HARP, WEBGL, P2D
hybrid.day.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.day.vector H.map.layer.TileLayer Features and labels that can be rendered over the satellite map HARP
hybrid.day.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
hybrid.night.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.night.vector H.map.layer.TileLayer Features and labels that can be rendered over the satellite map in night mode HARP
hybrid.night.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
hybrid.liteday.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.liteday.vector H.map.layer.TileLayer Reduced features and labels that can be rendered over the satellite map HARP
hybrid.liteday.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
hybrid.litenight.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.litenight.vector H.map.layer.TileLayer Reduced features and labels that can be rendered over the satellite map in night mode HARP
hybrid.litenight.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
hybrid.logistics.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.logistics.vector H.map.layer.TileLayer Reduced features and labels that can be rendered over the satellite map HARP
hybrid.logistics.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
hybrid.logisticsnight.raster H.map.layer.TileLayer Satellite map without features and labels with the color correction applied HARP
hybrid.logisticsnight.vector H.map.layer.TileLayer Reduced features and labels that can be rendered over the satellite map in night mode HARP
hybrid.logisticsnight.traffic H.map.layer.TileLayer Overlay with traffic flow and incidents markers that can be rendered over the satellite map HARP
Example
// Create the default layers
var layers = platform.createDefaultLayers({pois: true});

// Add traffic overlay to the map
map.addLayer(layers.vector.traffic.map);

createHybridLayers (styleConfig, onSuccess, onError)

This method creates hybrid map layers. A hybrid map consists of raster satellite base layer and vector layers on top. Layers created by this method can be used only when the Map is instantiated with H.Map.EngineType.HARP engineType. See: H.Map.Options.

Name Type Description
styleConfig Object | string

The hybrid style configuration. Can be either a configuration object or URL to the configuration. The URL can be absolute or relative, but should end with .json extension.

onSuccess function(!Object.<string, !H.map.layer.TileLayer>)

A callback function to be called once layers are successfully created. A callback accepts an object with 3 layers: raster, vector and traffic.

onError function(Error)

A callback function to be called if an error occurs during the layers creation.

Example
const hybridStyleConfig = {
  "base": {
    "style": "oslo",
    "scheme": "hybrid.day"
  },
  "definitions": {
    "Street.Category0.Color": "#ff0000",
    "Satellite.Texture.Gamma": 1.2,
    "Satellite.Texture.Brightness": 0.7
  }
};
platform.createHybridLayers(hybridStyleConfig, (layers) => {
  map.setBaseLayer(layers.raster);
  map.addLayer(layers.vector);
  map.addLayer(layers.traffic)
}, console.error);

createService (Service, opt_options)H.service.Service

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

Name Type Description
Service function(Object=)

The constructor of the service to instantiate

opt_options Object optional

Contains configuration options for a given service

Returns:
Type Description
H.service.Service An service instance

getBaseUrl ()H.service.Url

To obtain the currently used base URL.

Returns:
Type Description
H.service.Url The current base URL

getCustomLocationService (opt_options)H.service.extension.customLocation.Service Deprecated : since 3.1.30.12

To obtain a new instance of H.service.extension.customLocation.Service to query the HERE Fleet Telematics API endpoints related to creation, modification and retrieval of the custom data layers.

Name Type Description
opt_options H.service.Options optional

Configuration options of the service

Returns:
Type Description
H.service.extension.customLocation.Service The service instance

getCustomRoutingService (opt_options)H.service.extension.customRoute.Service Deprecated : since 3.1.30.12

To obtain a new instance of H.service.extension.customRoute.Service to query the custom route endpoint of the HERE Fleet Telematics API.

Name Type Description
opt_options H.service.Options optional

Configuration options of the service

Returns:
Type Description
H.service.extension.customRoute.Service The service instance

getGeocodingService (opt_options)H.service.GeocodingService Deprecated : since 3.1.30.12

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

Name Type Description
opt_options H.service.GeocodingService.Options optional

Configuration options for geocoding service

Returns:
Type Description
H.service.GeocodingService The created GeocodingService instance

getGeofencingService (opt_options, opt_version)H.service.GeofencingService | H.service.extension.geofencing.Service

To create a new instance of either H.service.extension.geofencing.Service or H.service.GeofencingService to query the selected Geofencing API. For compatibility reasons the class defaults to the deprecated HERE Fleet Telematics API, new applications should provide the optional opt_version parameter to get access to the new HERE Geofencing API v8

Name Type Description
opt_options H.service.Options optional

Configuration options for Geofencing service

opt_version number optional

Indicates the optional version of the Geofencing API to use, allowed values are 8 for the HERE Geofencing API v8 or undefined for the deprecated HERE Fleet Telematics API. Default is undefined.

Throws:
Returns:
Type Description
H.service.GeofencingService | H.service.extension.geofencing.Service The corresponding geofencing service instance.

getIMLService (opt_options)H.service.iml.Service

This method returns an instance of H.service.iml.Service to query the HERE Interactive Map Layer Data API.

Name Type Description
opt_options H.service.iml.Service.Options optional

Configuration options for the IML service.

Returns:
Type Description
H.service.iml.Service The created IML service instance.

getMapTileService (opt_options)H.service.MapTileService

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

Name Type Description
opt_options H.service.MapTileService.Options optional

Configuration options for map tile service

Returns:
Type Description
H.service.MapTileService The created map tile service instance

getMetaInfoService (opt_options)H.service.metaInfo.Service

This method returns an instance of H.service.metaInfo.Service to query the Map Tile API Metainfo Tiles

Name Type Description
opt_options H.service.metaInfo.Service.Options optional

Configuration options for meta info service

Returns:
Type Description
H.service.metaInfo.Service The created MetaInfo 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.

Name Type Description
opt_options H.service.omv.Service.Options optional

Configuration options for OMV service

Returns:
Type Description
H.service.omv.Service The created OMV service instance

getPlacesService (opt_options)H.service.PlacesService Deprecated : since 3.1.30.12

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

Name Type Description
opt_options H.service.omv.Service.Options optional

Configuration options for places service

Returns:
Type Description
H.service.PlacesService The created PlacesService instance

getPlatformDataService (opt_options)H.service.extension.platformData.Service Deprecated : since 3.1.30.12

This method returns an instance of H.service.extension.platformData.Service to query the HERE Fleet Telematics API.

Name Type Description
opt_options H.service.Options optional

Configuration options of the service

Returns:
Type Description
H.service.extension.platformData.Service The created service instance

getPublicTransitService (opt_options)H.service.publicTransit.Service

This method returns an instance of H.service.publicTransit.Service to query the HERE Public Transit API.

Name Type Description
opt_options H.service.Options optional

Configuration options for Public Transit service.

Returns:
Type Description
H.service.publicTransit.Service The created Public Transit service instance.

getRasterTileService (opt_options)H.service.rasterTile.Service

To create a new instance of H.service.rasterTile.Service to query data from the HERE Raster Tile API endpoint.

Name Type Description
opt_options H.service.rasterTile.Service.Options optional

Configuration options for Raster Tile Service

Returns:
Type Description
H.service.rasterTile.Service The created Raster Tile Service instance

getRoutingService (opt_options, opt_version)H.service.RoutingService | H.service.RoutingService8

To create a new instance of H.service.RoutingService to query the selected Routing API. For compatibility reasons the class defaults to the deprecated Routing API v7, new applications should provide the optional opt_version parameter to get access to the new Routing API v8

Name Type Description
opt_options H.service.Options optional

Configuration options for routing service

opt_version number optional

Indicates the version of the Routing API to use, allowed values are 7 for the Routing API v7 and 8 for the Routing API v8. Default is 7.

Throws:
Returns:
Type Description
H.service.RoutingService | H.service.RoutingService8 The corresponding routing service instance.

getSearchService (opt_options)H.service.SearchService

To create a new instance of H.service.SearchService to query the Geocoding and Search API endpoints.

Name Type Description
opt_options H.service.Options optional

Configuration options for the Search service

Returns:
Type Description
H.service.SearchService The created SearchService instance

getTrafficService (opt_options, opt_version)H.service.traffic.Service | H.service.traffic.Service7

This method returns either an instance of H.service.traffic.Service or H.service.traffic.Service7 to query the selected Traffic API.

For compatibility reasons the class defaults to the deprecated HERE Traffic API and HERE Traffic Incident Data, new applications should provide the optional opt_version parameter to get access to the new Traffic API v7.

Name Type Description
opt_options H.service.traffic.Service.Options | H.service.Options optional

Configuration options for traffic service

opt_version number optional

Indicates the version of the Traffic API to use, allowed values are 6 for the Traffic API v6 and 7 for the Traffic API v7. Default is 6.

Throws:
Returns:
Type Description
H.service.traffic.Service | H.service.traffic.Service7 The corresponding traffic service instance.

getTrafficVectorTileService (opt_options)H.service.trafficVectorTile.Service

Creates a new instance of H.service.trafficVectorTile.Service to query data from the HERE Traffic Vector Tile API.

Name Type Description
opt_options H.service.trafficVectorTile.Service.Options optional

Configuration options for service

Returns:
Type Description
H.service.trafficVectorTile.Service The created service instance

getVenuesService (options, opt_version)H.venues.Service | H.venues.Service2

To create a new instance of H.venues.Service2 to query the Venues service. For the compatibility reasons the class defaults to the deprecated Venues service, new applications should provide the optional opt_version parameter to get access to the new Venues service.

Name Type Description
options H.venues.Service.Options optional

Configuration options for the Venues service

opt_version number.<(1|2)> optional

opt_version Indicates the version of the Venue service to use, allowed values are 1 for the legacy Venue service and 2 for the latest Venue service. Default is 1.

Returns:
Type Description
H.venues.Service | H.venues.Service2 The created Service instance

getWaypointsSequenceService (options)H.service.WaypointsSequenceService

Create a new instance of H.service.WaypointsSequenceService to query the Waypoints Sequence API at HERE Waypoints Sequence API v8

Name Type Description
options H.service.Options optional

Configuration options for Waypoints Sequence service

Throws:
Returns:
Type Description
H.service.WaypointsSequenceService The corresponding Waypoints Sequence service instance.

setBaseUrl (baseUrl)

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

Name Type Description
baseUrl H.service.Url

The new base URL to use

Type Definitions

H.service.Platform.DefaultLayersOptions Object

This type encapsulates options used to create default layers.

Properties:
Name Type Argument Description
tileSize number <optional>

Defines the raster tile size to be queried from the HERE Map Tile v2 or HERE Raster Tile v3. The default is 512

ppi number <optional>

A ppi parameter to use when querying tiles, the default is not specified. See Base Map Tile – Optional Query Parameters for more details. For layers with raster tiles from HERE Raster Tile API v3 a value > 72 means, that tiles designed for 400 ppi are used, otherwise 100 ppi.

lg string <optional>

An identifier of the primary language, the default is not specified

lg2 string <optional>

An identifier of the secondary language, the default is not specified

style string <optional>

An optional 'style' definition 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), valid for the "HERE Vector Tile API", "HERE Map Tile v2" and "HERE Raster Tile API v3". For layers from HERE Map Tile v2, also a mask for the POI Categories can be provided as described in the documentation for Filter POIs by Categories. By default POIs are disabled.

crossOrigin string <optional>
<nullable>

The value to use for the crossOrigin attribute of the tile images, if omitted the attribute is set to "anonymous". For more details see MDN web docs. Note that storing of content is not possible if crossOrigin is defined and the value is neither "anonymous" nor "use-credentials"; see also H.Map#storeContent

engineType H.Map.EngineType <optional>

The engine type in use, it is used to properly configure the providers default style. Default is H.Map.EngineType.WEBGL.

politicalView string

The geopolitical view of the map data in ISO 3166-1 alpha-2 standard. The default value corresponds to the international geopolitical view.

H.service.Platform.Options Object

This type encapsulates the configuration (initialization) options for an instance of Platform.

Properties:
Name Type Argument Description
apikey string

The application ID to identify the client for the platform services (mandatory).

baseUrl H.service.Url <optional>

The base URL of the platform, the default is https://api.here.com.

headers Object <optional>

A map of HTTP headers to be sent with each request made by each service (unless headers option is overwritten on a per-service basis).

servicesConfig Object <optional>

A dictionary of configurations for services that are using non-default options. It overrides service's defaults but does not override options explicitly passed to service's constructor.