カスタム設定

この資料では、プロキシ経由で API にアクセスする必要がある場合、またはプラットフォームのカスタムインストールが存在する場合に、既定のプラットフォーム URL を変更する方法について説明します。

ドメイン名を設定しています

デフォルトでは、 JavaScript for Maps API は HERE platform API を使用するように設定されています。 ベクトルマップタイルのこの設定を変更するには、 API を実行時、つまり API を使用してアプリケーションスクリプトで設定する必要があります。

次のスニペットは、個々のサービスのリクエストドメインを変更する方法を示しています。

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

// Vector Tile service
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
};

// Geocoding service
domainConfig[H.service.GeocodingService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'search/6.3', getoptions
  ),
  reverseSubDomain: 'customreverse'
};

// Routing service
domainConfig[H.service.RoutingService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'routing/6.2', getoptions
  )
};

// Map tile service
domainConfig[H.service.MapTileService.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'maptile/2.1', getoptions
  ),
  // optional if respected subdomain should be omitted
  ignoreTypes: ['base', 'aerial', 'traffic'],
  // optional if sharding scheme is different from default
  // null when sharding is not available
  shards: ['a', 'b', 'c', 'd']
};

// Traffic service
domainConfig[H.service.traffic.Service.CONFIG_KEY] = {
  baseUrl: new H.service.Url(
    'https', 'custom.domain', 'traffic/6.0', 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
 */

サービスパスを変更しています

個々のサービスで、ドメイン設定を変更せずに別のパスを使用するように設定することもできます。 これは、 RESTful サービスが、同様の機能を公開する追加のエンドポイント ( 国別のエンドポイントなど ) を提供する場合に役立ちます。

以下のコード スニペットは、このようなユースケースを示しています。

// 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.Style('https://js.api.here.com/v3/3.1/styles/omv/miami/normal.day.yaml'));
var omvLayer = new H.map.layer.TileLayer(omvProvider, {max: 22});

/**
 * The application can use the layer above as normal
 */

上記のコードで は、通常どおりH.service.Platformオブジェクトが作成 され、ファクトリメソッドgetOMVServicepathオプションを渡すことによって、カスタムの Vector タイルサービスインスタンスが作成されます。 の作成に関連 services するその他のオプションについては、ガイドの『 API リファレンス 』を参照してください。

」に一致する結果は 件です

    」に一致する結果はありません