1

我们在 ng angular 应用程序中使用 harp.gl,但是在连接到数据源时遇到了问题,这与我们在 yarn 演示中的工作方式相同。
我们将数据源创建为:

const dataSource = new OmvDataSource({
  baseUrl: "https://vector.hereapi.com/v2/vectortiles/base/mc",
  apiFormat: APIFormat.XYZOMV,
  styleSetName: "tilezen",
  authenticationCode: apikey,
  authenticationMethod: {
        method: AuthenticationMethod.QueryString,
        name: "apikey"
  }
});

并创建一个 MapView 为:

const mapView = new MapView({
    canvas: mapCanvas,
    theme: "assets/resources/berlin_tilezen_base.json",
    // note, this URL may vary depending on configuration of webpack
    // for this example, it is assumed that app is server from project root
    decoderUrl: "harp-gl-decoders.bundle.js"
    // note, this URL may vary depending on configuration of webpack
    // for this example, it is assumed that webpack emits bundles to project root
});

并添加数据源:

mapView.addDataSource(dataSource);

并在控制台上看到这个:

[WDS] App updated. Reloading...  
Angular is running in the development mode. Call enableProdMode() to enable the production mode.  
MapView: Failed to connect to datasource anonymous-datasource#1: Error during worker initialization  
[WDS] Live Reloading enabled.  

这在网页的调试控制台上:

:4200/decoder.bundle.js:1 Failed to load resource: the server responded with a status of 404 (Not Found)  
ConsoleChannel.js:15 MapView: Failed to connect to datasource anonymous-datasource#1: Error during worker initialization  

我花了很多时间抓住稻草,愿意接受任何帮助。

4

2 回答 2

0

如此处所示,您可能需要在页面标题中添加额外的元标记。

<head>
    <meta http-equiv="Content-Security-Policy" content="child-src blob:">
</head>
于 2020-06-25T19:55:54.580 回答
0

最近在此处添加了 Angular 的入门指南: https ://github.com/heremaps/harp.gl/blob/master/docs/GettingStartedAngular.md

几乎在最后,它将decoder.bundle.js 添加到angular.json 的资产部分:

        "assets": [
          "src/favicon.ico",
          "src/assets",
          {
            "glob": "decoder.bundle.js",
            "input": "./",
            "output": "./"
          }
        ],
于 2020-08-18T20:37:09.343 回答