-
Notifications
You must be signed in to change notification settings - Fork 6
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
update raster source url? #111
Comments
You have to remove and re-add the layer with the new url. |
Thank you, but how do I do that? I don't see any Do I (If there is no current function for this, I would be willing to try to update the code & do a pull request, if that would help) |
You are right. There are not mappings for all JavaScript Map methods but with the powerful Map.add_call method you can trigger any In your case you have to take a look at Map.removeLayer. As you can see the only argument ist the m = Map()
# ...
m.add_call("removeLayer", layer_id) |
That works great! Thank you. BTW, I removed both the layer and the source, then added them both again. Was that necessary?
|
Yes, that is correct because a source can be consumed by multiple layers. Therefore, it is not removed automatically if a layer is removed. And maybe you want to use the source later on. So if you really want to update it as in your case, you have to remove it. I think only data of a GeoJSON Source can be updated without removing it. |
How do I update the url in a raster source?
This works fine when the layer source is GeoJSONSource:
m.set_data(JSON_LAYER_ID, new_data) # works great, but only for GeoJSON source
is there an equivalent for raster layers? Maybe something like:
m.set_raster_url(RASTER_LAYER_ID, new_url) # no such method
I tried this, but it doesn't do anything useful:
m.set_layout_property(RASTER_LAYER_ID, 'url', new_url) # nope
Thank you.
The text was updated successfully, but these errors were encountered: