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

Dynamic Raster Source Support #247

Closed
kildareflare opened this issue Aug 28, 2019 · 4 comments
Closed

Dynamic Raster Source Support #247

kildareflare opened this issue Aug 28, 2019 · 4 comments
Assignees

Comments

@kildareflare
Copy link

Describe the bug
I have a source of type 'raster'.
When I change the source url the map does not update.
The only way to get the map to update is remove the Source component and add it in again with the new url.

Looking at the source of Source component I see that the source is only swapped if the id or type is changed.

  if (id !== prevId || source.type !== prevSource.type) {
      this._map.removeSource(prevId);
      this._map.addSource(id, source);
      return;
    }

However even if I toggle the id to force a source update the layers will not be updated as raster is not handle here:

  if (source.type === 'geojson' && prevSource.type === 'geojson') {
      this._updateGeoJSONSource(id, prevSource, source);
      return;
    }

    if (source.type === 'vector' && prevSource.type === 'vector') {
      this._updateVectorSource(id, prevSource, source);
    }

Is this by design?
Is this related to this PR?: mapbox/mapbox-gl-js#8048

To Reproduce
Steps to reproduce the behavior:

  1. Create a map with a raster source
  2. Assign a url
  3. the map renders appropriate raster tiles
  4. Change the url
  5. the map does not update with new raster tiles

Expected behavior
When the url is changed for a raster source, the tiles should update.

@stepankuzmin stepankuzmin self-assigned this Aug 29, 2019
@kildareflare
Copy link
Author

Awesome, thanks for the quick response @stepankuzmin, I'll test this shortly.

One more question though. Is there a reason why the source is not updated on url change?
E.g. it is only currently updated on change of id or type

    if (id !== prevId || source.type !== prevSource.type) {
      this._map.removeSource(prevId);
      this._map.addSource(id, source);
      return;
    }

But in my use case I need to change the URL when the user toggles on/off layers.
The MapBox Url I have has embedded in an array, which can change based on user selection.

E.g. the show param in this URL will change

https://gisserver:6443/arcgis/rest/services/myService/export?>bbox=100.5,-100.334,200,-200&token=TOKEN&layers=show:2,3&size=256,256&imageSR=38>57&bboxSR=3857&format=png&transparent=true&f=image&dpi=96

Currently I would have to force a reload by either toggling the id or type; it would be a lot nicer to simply change the URL.

Or is the a reason why this is not possible?

@stepankuzmin
Copy link
Member

@kildareflare could you please provide an example for this issue? I can't reproduce this.

@anatolysukhanov
Copy link

Does #251 have anything to do with this?

@stepankuzmin
Copy link
Member

This should be resolved by be3aa67

Try upgrading to the latest 1.11.0 version and feel free to reopen this issue if it doesn't work.

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