0

The following is the error when I run my Angular Application which contains a mapbox in it. It does not display the map in stackblitz whereas it does, when run in the local machine. I have added the access token in mapbox. Has anyone else faced this issue?

AppComponent_Host.ngfactory.js? [sm]:1 ERROR Error: An API access token is required to use Mapbox GL. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes
    at N._makeAPIURL (mapbox.js:184)
    at N.normalizeStyleURL (mapbox.js:74)
    at i.loadURL (style.js:214)
    at r._updateStyle (map.js:1262)
    at r.setStyle (map.js:1233)
    at new r (map.js:449)
    at AppComponent.ngOnInit (VM13107 app.component.ts:38)
    at checkAndUpdateDirectiveInline (provider.ts:212)
    at checkAndUpdateNodeInline (view.ts:429)
    at checkAndUpdateNode (view.ts:389)

1 Answers1

1

It seems that your api access token is not correct recognized.

Please check some working stackblitz instances for a correct configuration.

Your app.module.ts should contain NgxMapboxGLModule.withConfig or NgxMapboxGLModule.forRoot together with your api access token.

   NgxMapboxGLModule.withConfig({
      accessToken: 'myCustomTokenComesHere'
    })

E.g.:

For further inspections, please share your Stackblitz (maybe without your Access token, if you don't want to make it public).

zerocewl
  • 11,401
  • 6
  • 27
  • 53