HERE Data Hub はリアルタイムの位置データ管理サービスで、 CLI や HERE Studio などのデータ ハブツールのセットを使用して、地理空間データのアップロードと管理を簡単に行うことができます。 HERE Maps API for Javascript を使用すると、データ ハブスペースとして提示されたデータを既存のアプリケーションに簡単に追加できます。 また、 HERE Maps API for Javascript では、ルーティング、ジオ コーディング、 Fleet Telematics 拡張データセットなどの HERE サービスを使用する新しいアプリケーションをデータ ハブとともに構築できます。
// provided that the platform and the map are instantiated.const service = platform.getXYZService({token:<YOUR_DATA_HUB_ACCESS_TOKEN>,});// create a provider for the public buildings dataconst buildingsSpaceProvider =newH.service.xyz.Provider(service,<DATA_HUB_SPACE_ID>,{'min':14});const buildingsSpaceLayer =newH.map.layer.TileLayer(buildingsSpaceProvider);// add a layer to the map
map.addLayer(buildingsSpaceLayer);// create a provider for the custom user defined dataconst customSpaceProvider =newH.service.xyz.Provider(service,<DATA_HUB_SPACE_ID>);const customSpaceLayer =newH.map.layer.TileLayer(customSpaceProvider);// add a layer to the map
map.addLayer(customSpaceLayer);
上記の例で は、データ ハブが デフォルトのスタイルおよび設定で使用されていますが、 API では、レイヤーのスタイルを変更してインタラクティブにすることができます。 次のコードでは、前の例の初期ステップを次のように拡張しています。
建物レイヤーの外観(この場合は色)を変更します。
Buildings レイヤーをインタラクティブにし、タイルプロバイダに TAP イベントリスナーを登録します。
// get the style for the layervar style = buildingsSpaceProvider.getStyle();// change the color of the polygons
style.setProperty('layers.xyz.polygons.draw.polygons.color','red');
style.setInteractive(['xyz'],true);
buildingsSpaceProvider.addEventListener('tap',(evt)=>{console.log(evt.target.getData())});// make the objects within the provider interactive
style.setInteractive(['xyz'],true);// add an event listener to the provider// the event listener outputs into the console the data associated // with the object
buildingsSpaceProvider.addEventListener('tap',(evt)=>{
console.log(evt.target.getData())});
// get the style for the layervar style = buildingsSpaceProvider.getStyle();// set the configuration for the label display
buildingsSpaceLayer.getProvider().getStyle().setProperty('layers.xyz.labels',{draw:{text:{text_source:'properties.street',// collide: false,priority:0,font:{size:'14px',fill:'blue',stroke:{color:'white',width:'1px'}}}}});