Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing mgl-image-source coordinates dynamically causes issues #139

Closed
sprattek opened this issue Apr 24, 2019 · 5 comments
Closed

Changing mgl-image-source coordinates dynamically causes issues #139

sprattek opened this issue Apr 24, 2019 · 5 comments

Comments

@sprattek
Copy link

sprattek commented Apr 24, 2019

I'm having the same issue as @HarelM at #10 with only difference that I'm using 'mgl-image-source' and changing the coordinates dynamically.

<mgl-image-source
  id="floorplanImageSource"
  [url]="floorplanImageSourceOptions.url"
  [coordinates]="floorplanImageSourceOptions.coordinates"
></mgl-image-source>
<mgl-layer
  id="floorplanImageLayer"
  source="floorplanImageSource"
  type="raster"
  [paint]="floorplanImageLayerOptions.paint"
  [layout]="floorplanImageLayerOptions.layout"
></mgl-layer>

So after doing this in my component

this.floorplanImageSourceOptions.coordinates = newCoodinates

it throws me these errors

Source "floorplanImageSource" cannot be removed while layer "floorplanImageLayer" is using it.
And then There is already a source with this ID

Originally posted by @sprattek in #10 (comment)

@Wykks
Copy link
Owner

Wykks commented Jun 7, 2019

In lots of Inputs of source, I'm doing a

this.ngOnDestroy();
this.ngOnInit();

I knew this was not super smart 😅
I don't remember when mapbox-gl did this change but yep, it doesn't work anymore.
I'll try to find a way around this or simply move theses inputs as "Init inputs" only.

@Wykks
Copy link
Owner

Wykks commented Jun 16, 2019

Note: there's a new updateImage method, in mapbox-gl v0.54.0 (mapbox/mapbox-gl-js#7999). I'll update the image component accordingly. (the image component is one of the few component using this bad pattern destroy/init).

@dmytro-gokun
Copy link
Collaborator

@Wykks As far as i can see. for imageSource there are some methods to update it after creation: https://docs.mapbox.com/mapbox-gl-js/api/#imagesource
I'll try to use those.

@Wykks
Copy link
Owner

Wykks commented Jun 26, 2019

Yep I was refering to that in my previous post :)
Not sure to have the time this week, so would be great if you can take a look.

Other components probably don't have a magical update method (I searched them before making this bad pattern), so I guess we can only changes input from dynamic to init only (for v4).

@dmytro-gokun
Copy link
Collaborator

@Wykks Yep, i'll try to work on this shortly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants