Guidesv3.2 API Referencev3.1 API Reference
Guides

Set custom domain names and service paths

 HERE Maps API for JavaScript version 3.2

This article provides guidance on modifying the default platform URLs when accessing APIs through a proxy or when installing the platform with custom configurations.

Setting the domain name

By default, the Maps API for JavaScript is configured to use HERE platform APIs. To modify this configuration for vector map tiles, search, or routing within your own installation, you must configure the API at runtime using application scripts.

The following code snippet demonstrates how to change the request domain for individual services.

// configuration object, is passed to the H.service.Platform
const domainConfig = {};
const getoptions = {
  apikey: '<API_KEY>'
};

// HERE Vector Tile API v2
domainConfig[H.service.omv.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v2/vectortiles/core/mc', getoptions
  ),
  subdomain: 'subdomain' // optional, if subdomain is not needed, null must be passed
};

// HERE Geocoding and Search API v7
domainConfig[H.service.SearchService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v1', getoptions
  )
};

// HERE Interactive Map Layer Data API
domainConfig[H.service.iml.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'interactive/v1/catalogs', getoptions
  )
};

// HERE Public Transit API v8
domainConfig[H.service.publicTransit.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v8', getoptions
  )
};

// HERE Routing API v8
domainConfig[H.service.RoutingService8.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v8/routes', getoptions
  )
};

// HERE Raster Tile API v3
domainConfig[H.service.rasterTile.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v3', getoptions
  )
};

// HERE Traffic API v7
domainConfig[H.service.traffic.Service7.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v7', getoptions
  )
};

// HERE Traffic Vector Tile API v2
domainConfig[H.service.trafficVectorTile.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v2', getoptions
  )
};

// HERE Waypoints Sequence API v8
domainConfig[H.service.WaypointsSequenceService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v8', getoptions
  )
};

// HERE Geofencing API v8
domainConfig[H.service.GeofencingService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'v8', getoptions
  )
};

// Create an instance of the platform
var platform = new H.service.Platform({
  apikey: '<API_KEY>',
  servicesConfig: domainConfig
});

/**
 * The rest of the application remains unchanged
 */ 

Changing the service path

You can configure individual services to use different paths without modifying the domain configuration. This approach can be useful when you have RESTful services that provide additional endpoints with similar functionality, such as country-specific endpoints.

The following code snippet demonstrates this use case:

// Create an instance of the platform
var platform = new H.service.Platform({
  apikey: '<API_KEY>'
});

// create a service that calls the custom endpoint
var omvService = platform.getOMVService({path:  'custom/vector/endpoint'});
// create a provider and a layer that use the custom service
var omvProvider = new H.service.omv.Provider(omvService,
    new H.map.render.harp.Style('https://js.api.here.com/v3/3.2/styles/harp/oslo/normal.day.json'));
var omvLayer = new H.map.layer.TileLayer(omvProvider, {max: 22});

/**
 * The application can use the preceding layer configuration as normal
 */

The preceding code creates the H.service.Platform object, and a custom Vector Tile Service instance is created by passing the path option to the factory method getOMVService. For more information on creating services, see the API Reference.