harp.gl и angular нг - PullRequest
       27

harp.gl и angular нг

1 голос
/ 19 июня 2020

Мы используем harp.gl в приложении ng angular, но у нас проблемы с подключением к источникам данных так же, как в нашей демонстрации 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  

Я потратил много часов на str aws и приму любую помощь.

Ответы [ 2 ]

0 голосов
/ 18 августа 2020

Недавно здесь было добавлено руководство по началу работы для 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": "./"
          }
        ],
0 голосов
/ 25 июня 2020

Как здесь , вам может потребоваться дополнительный метатег в заголовке страницы

<head>
    <meta http-equiv="Content-Security-Policy" content="child-src blob:">
</head>
...