Wykks / ngx-mapbox-gl

Angular binding of mapbox-gl-js
https://wykks.github.io/ngx-mapbox-gl
MIT License
344 stars 139 forks source link

Cannot set property config #390

Open vladkasianenko opened 1 year ago

vladkasianenko commented 1 year ago

Possible duplicate of #373.

Console output:

    Uncaught TypeError: Cannot set property config of [object Module] which has only a getter
    at MapService.assign (ngx-mapbox-gl.mjs:767:32)
    at Object.next (ngx-mapbox-gl.mjs:34:22)
    at ConsumerObserver.next (Subscriber.js:91:33)
    at SafeSubscriber._next (Subscriber.js:60:26)
    at SafeSubscriber.next (Subscriber.js:31:18)
    at throwIfEmpty.js:9:24
    at OperatorSubscriber._next (OperatorSubscriber.js:13:21)
    at OperatorSubscriber.next (Subscriber.js:31:18)
    at take.js:12:32
    at OperatorSubscriber._next (OperatorSubscriber.js:13:21)

ENV:

>ng version

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/

Angular CLI: 14.2.10
Node: 18.12.1 (Unsupported)
Package Manager: npm 8.19.2
OS: win32 x64

Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                              Version
--------------------------------------------------------------
@angular-devkit/architect            0.1402.10
@angular-devkit/build-angular        14.2.10
@angular-devkit/core                 14.2.10
@angular-devkit/schematics           14.2.10
@angular/cdk                         14.2.7
@angular/cli                         14.2.10
@angular/flex-layout                 14.0.0-beta.41
@angular/material                    14.2.7
@angular/material-date-fns-adapter   14.2.7
@schematics/angular                  14.2.10
rxjs                                 7.5.5
typescript                           4.6.4
ngx-mapbox-gl            9.1.0
mapbox-gl            2.12.0

I use this code in my shared.module.ts:

imports: [
   NgxMapboxGLModule.withConfig({ accessToken: environment.NG_APP_MAP_BOX_ACCESS_TOKEN }),
],
exports: [
   NgxMapboxGLModule,
]
sandikbarr commented 1 year ago

I believe this issue setting the accessToken is in fact a duplicate of #373 and that is was resolved with PR #374

I am however seeing a very similar error when attempting to set the customMapboxApiUrl on the map component.

ngx-mapbox-gl.mjs:767 Uncaught TypeError: Cannot set property config of [object Module] which has only a getter
    at MapService.assign (ngx-mapbox-gl.mjs:767:1)
    at ngx-mapbox-gl.mjs:34:1
    at Object.next (Subscriber.js:123:1)
    at Subscriber._next (Subscriber.js:63:1)
    at Subscriber.next (Subscriber.js:34:1)
    at throwIfEmpty.js:10:1
    at OperatorSubscriber._this._next (OperatorSubscriber.js:11:1)
    at Subscriber.next (Subscriber.js:34:1)
    at take.js:12:1
    at OperatorSubscriber._this._next (OperatorSubscriber.js:11:1)

I see that the Mapbox config.API_URL property has been changed to be a getter, and they have a baseApiUrl option that can be set. I will submit a PR.