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

Angular 17 Support? #410

Closed MO-Lewis closed 1 month ago

MO-Lewis commented 10 months ago

Hi there!

Just wondering what the timeframe is on Angular 17 support, if ever. I'm assuming that the reason it's not working for me is just because of the lack of Angular 17 support, but here's the error anyway if that helps.

Currently, my app config imports the library like so:

app.config.ts:

export const appConfig: ApplicationConfig = {
  providers: [provideRouter(routes), provideAnimations(), importProvidersFrom(
    NgxMapboxGLModule.withConfig({
      accessToken: '[KEY]', // Optional, can also be set per map (accessToken input of mgl-map)
    })
  )]
};

And I've declared it in my map.component.ts like this:

@Component({
  selector: 'app-map',
  standalone: true,
  imports: [
    CommonModule,
    HttpClientModule,
    HttpClientJsonpModule,
    NgxMapboxGLModule
  ],
  templateUrl: './map.component.html',
  styleUrl: './map.component.scss'
})

However, I get this error:

[ERROR] Cannot assign to import "baseApiUrl"

    node_modules/ngx-mapbox-gl/fesm2022/ngx-mapbox-gl.mjs:100:17:
      100 │         MapboxGl.baseApiUrl = options.customMapboxApiUrl;
          ╵                  ~~~~~~~~~~

  Imports are immutable in JavaScript. To modify the value of this import, you must export a setter
  function in the imported file (e.g. "setBaseApiUrl") and then import and call that function here
  instead.

\mapbox-dashboard-test\node_modules\vite\node_modules\esbuild\lib\main.js:1649
  let error = new Error(`${text}${summary}`);
              ^

Error: Build failed with 1 error:
node_modules/ngx-mapbox-gl/fesm2022/ngx-mapbox-gl.mjs:100:17: ERROR: Cannot assign to import "baseApiUrl"

Thanks in advance for any help!

playnox commented 10 months ago

Same issue here... Please update to support v17

rexydye commented 10 months ago

Also waiting for an update, it would be nice

jimmyjaramillo7 commented 10 months ago

Just comment on these lines, it worked for me. imagen path: node_modules/ngx-mapbox-gl/fesm2022/ngx-mapbox-gl.mjs lines: 33,34,35

relu91 commented 8 months ago

Thanks @jimmyjaramillo7 for the workaround for people who don't know and wants still to ship the product, they can use this awesome package to properly patch ngx-mapbox-gl in their node modules.

certifirm commented 7 months ago

ZZZZZZZZZ

jongbonga commented 7 months ago

that's weird... I'm using Angular 17.0.2 without an issue, I didn't need to make any changes... Maybe it's becuase I'm still on "mapbox-gl": "2.15.0" not sure

"ngx-mapbox-gl": "^10.0.0",
"mapbox-gl": "^2.15.0"
BojanKogoj commented 5 months ago

This was reported in https://github.com/Wykks/ngx-mapbox-gl/issues/403 and fixed, but new version was never released.

that's weird... I'm using Angular 17.0.2 without an issue, I didn't need to make any changes... Maybe it's becuase I'm still on "mapbox-gl": "2.15.0" not sure

"ngx-mapbox-gl": "^10.0.0",
"mapbox-gl": "^2.15.0"

That's because it breaks only if you use esbuild. I have same versions but throws an error.

RaviHadalgi commented 5 months ago

Need support for angular 17.3.7, unable to install the package. Map-box is used in the dashboard page, cannot finish till this is done. Need update asap. Thanks.