The powerful combination of harp.gl and Angular NG

We've integrated harp.gl into our ng Angular application, but we're encountering issues when trying to connect to data sources that previously worked in our yarn demo.
The datasource is created as follows:

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"
  }
});

and the MapView is created like this:

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
});

then the data source is added using the following code:

mapView.addDataSource(dataSource);

This results in the following messages being displayed on the console:

[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.  

and the webpage's debug console shows:

: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  

I've spent countless hours troubleshooting and am open to any assistance.

Answer №1

If you refer to this resource, it suggests adding an extra meta tag in the head section of your page.

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

Answer №2

Check out the new guide for getting started with Angular that was recently added here: https://github.com/heremaps/harp.gl/blob/master/docs/GettingStartedAngular.md

One important step towards the end is adding decoder.bundle.js to the asset section of the angular.json file:

        "assets": [
          "src/favicon.ico",
          "src/assets",
          {
            "glob": "decoder.bundle.js",
            "input": "./",
            "output": "./"
          }
        ],

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can you give me some insights about what an Action Creator is?

function createRefDoneAction(widgetsArray: widget[]): WidgetAction { return { type: actionTypes.REFRESH_WIDGET_DONE, widgets: widgetsArray }; } Could you please clarify the necessity of having two sets of parameters (e.g. 'wid ...

Display permanent components in Angular while nesting components

Currently, I am incorporating the admin module within the main app module in my project Within the admin module, there are 2 components - register and login. Additionally, the admin module has its own routing module. Now, my task is to create a navbar sp ...

What is the best way to prevent event propagation in d3 with TypeScript?

When working with JavaScript, I often use the following code to prevent event propagation when dragging something. var drag = d3.behavior.drag() .origin(function(d) { return d; }) .on('dragstart', function(e) { d3.event.sourceEvent ...

Swiping in Angular2 gets a new twist with Swiper typings

Having trouble importing typings for Swiper into my Angular 2 project. After installing Swiper and its typings using npm, I tried including Swiper in my component like this: import { Swiper } from 'swiper'; However, Atom displays an error: ...

Exclude all .js files from subdirectories in SVN

In my typescript project, I am looking to exclude all generated JavaScript files in a specific folder from SVN. Is there a convenient command or method to achieve this for all files within the directory? ...

I have a quick question: What is the most effective method for creating PDF templates with Angular and .NET 6, specifically for designs that feature heavy

Seeking the optimal solution for creating PDF templates using Angular and .NET 6? Specifically looking to design templates that heavily feature tables. In my exploration of efficient PDF template creation with Angular and .NET 6, I ventured into using pdf ...

Defining assertions with specified type criteria

Looking to do something special in TypeScript with a class called Foo. I want to create a static array named bar using const assertion, where the values are restricted to the keys of Foo. This array will serve as the type for the function func while also a ...

Converting Objects to Arrays with Angular Observables

After searching extensively on SO for answers regarding item conversions in Javascript/Angular, I couldn't find a solution that addresses my specific problem. When retrieving data from Firestore as an object with potential duplicates, I need to perfor ...

Guide on creating frozen columns in an Angular 2 table with the ability to scroll through multiple columns

Within my table, there are 3 columns that must always remain on the left side. Additionally, there is a column containing a grid where each element represents an hour of the day, requiring it to be scrollable. I have attempted various proposed solutions, ...

Dynamically populate dropdown menu with values extracted from dataset

I'm currently working on a dropdown menu that needs to be updated dynamically using the data set below: this.additionalPercentages = this.offer.offerData.wellbeing.retirementPackages[0].additionalVoluntaryContributionPercentages; When I console this ...

Guide on verifying the snack bar's visibility and performing an action in e2e test using Protractor

Currently, I am conducting e2e testing using Protractor and encountering an issue with the snack bar feature. Here is a screenshot of the functioning app: Demo The dilemma lies in verifying the visibility of the snackbar on the page and how to execute the ...

After the installation of Storybook, there is a duplicate identifier error that arises with 'LibraryManagedAttributes'

Upon running the command npx storybook@latest init for setting up Storybook, which results in modifying package.json, I encounter an issue where I cannot run the project using npm due to: Error: node_modules/@types/react-dom/node_modules/@types/re ...

The expected property 'label' is not found in the object type '{ handleClick: () => void; }', but it is required in the object type '{ handleClick: () => void; label: string; }'

I'm encountering difficulties when describing the types of my props. The issue arises with the following code: <PostButton handleClick={props.upvote}/> <PostButton2 handleClick={props.downvote}/> An error message is displayed: Pro ...

Securely connecting Angular front end with NodeJS backend server using HTTPS encryption

I am currently using a frontend built with Angular 7 and ngx-admin, along with a backend developed in nodeJS and Express. The issue: The Angular frontend uses HTTPS to communicate with the backend via HTTP. This has caused the following problem: Mixed Co ...

Experiencing a problem with updating records in angular?

angular version: Angular CLI: 9.0.0-rc.7 I have encountered an issue while trying to update a record. After clicking on the edit icon, I am able to make changes to the record in the form. However, when I click on the Edit Button, the record gets updated i ...

What is the best way to add a value to a nested JSON array in Angular 5?

Need help transferring nested JSON data format from Web API to Angular5 {"contractId":1, "contractName":"Temp", "contractServiceList":[ {"id":1, "serviceId":{"serviceId":1,"serviceName":"Emergency Room"}, "providerTier":"Tier 1", "coi ...

Issue found: Passing a non-string value to the `ts.resolveTypeReferenceDirective` function

Encountering the following error: Module build failed (from ./node_modules/ts-loader/index.js): Error: Debug Failure. False expression: Non-string value passed to ts.resolveTypeReferenceDirective, likely by a wrapping package working with an outdated res ...

The module declaration is triggering a lint error that reads "Unexpected token, expecting '{'"

To address the absence of available types for a library, I created the file omnivore.d.ts in TypeScript. Within this file, I added the following line: declare module '@mapbox/leaflet-omnivore' Upon running vue-cli-service lint in my project, an ...

Using Angular: How to access a component variable within a CSS file

I'm having issues with my css file and attempting to achieve the following: .login-wrapper { background-image: url({{imagePath}}); } Below is my component code: export class LoginComponent implements OnInit { imagePath: any = 'assets/discord ...

Building the Android release version of an Ionic Cordova app using the command `ionic cordova build android –prod –release` may encounter a failure when it

Having an issue with Ionic 3. Whenever I use cordova build android --prod --release, the APK shows a white screen after splash. Alternatively, when using ionic cordova build android --prod --release, I encounter the following error. https://i.stack.imgur. ...