カスタム設定
この資料では、プロキシ経由で API にアクセスする必要がある場合、またはプラットフォームのカスタムインストールが存在する場合に、既定のプラットフォーム URL を変更する方法について説明します。
ドメイン名を設定しています
デフォルトでは、 JavaScript for Maps API は HERE platform API を使用するように設定されています。 ベクトルマップタイルのこの設定を変更するには、 API を実行時、つまり API を使用してアプリケーションスクリプトで設定する必要があります。
次のスニペットは、個々のサービスのリクエストドメインを変更する方法を示しています。
const domainConfig = {};
const getoptions = {
apikey: '<API_KEY>'
};
domainConfig[H.service.omv.Service.CONFIG_KEY] = {
baseUrl: new H.service.Url(
'https', 'custom.domain', 'v2/vectortiles/core/mc', getoptions
),
subdomain: 'subdomain'
};
domainConfig[H.service.GeocodingService.CONFIG_KEY] = {
baseUrl: new H.service.Url(
'https', 'custom.domain', 'search/6.3', getoptions
),
reverseSubDomain: 'customreverse'
};
domainConfig[H.service.RoutingService.CONFIG_KEY] = {
baseUrl: new H.service.Url(
'https', 'custom.domain', 'routing/6.2', getoptions
)
};
domainConfig[H.service.MapTileService.CONFIG_KEY] = {
baseUrl: new H.service.Url(
'https', 'custom.domain', 'maptile/2.1', getoptions
),
ignoreTypes: ['base', 'aerial', 'traffic'],
shards: ['a', 'b', 'c', 'd']
};
domainConfig[H.service.traffic.Service.CONFIG_KEY] = {
baseUrl: new H.service.Url(
'https', 'custom.domain', 'traffic/6.0', getoptions
)
};
var platform = new H.service.Platform({
apikey: '<API_KEY>',
servicesConfig: domainConfig
});
サービスパスを変更しています
個々のサービスで、ドメイン設定を変更せずに別のパスを使用するように設定することもできます。 これは、 RESTful サービスが、同様の機能を公開する追加のエンドポイント ( 国別のエンドポイントなど ) を提供する場合に役立ちます。
以下のコード スニペットは、このようなユースケースを示しています。
var platform = new H.service.Platform({
apikey: '<API_KEY>'
});
var omvService = platform.getOMVService({path: 'custom/vector/endpoint'});
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});
上記のコードで は、通常どおりH.service.Platform
オブジェクトが作成 され、ファクトリメソッドgetOMVService
にpath
オプションを渡すことによって、カスタムの Vector タイルサービスインスタンスが作成されます。 の作成に関連 services
するその他のオプションについては、ガイドの『 API リファレンス 』を参照してください。