我们在ng角应用程序中使用harp.gl,但在连接数据源时遇到了困难,其方式与我们在纱线演示中使用的方式相同。 我们将数据源创建为:
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 我花了很多时间抓吸管,愿意接受任何帮助。
发布于 2020-06-25 19:55:54
作为在这里看到的,您可能需要在页面头中增加一个元标记。
<head>
<meta http-equiv="Content-Security-Policy" content="child-src blob:">
</head>发布于 2020-08-18 20:37:09
最近添加了一个关于角的入门指南: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": "./"
}
],https://stackoverflow.com/questions/62476658
复制相似问题