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

Is there any way to reload the source for the added tile layer? #302

Open
KostyaLocal opened this issue Sep 22, 2023 · 5 comments
Open

Is there any way to reload the source for the added tile layer? #302

KostyaLocal opened this issue Sep 22, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@KostyaLocal
Copy link

If I delete the layer and the source, the blinking occurs. I found that if I change tileUrl of source in js MapBox, it will reload, but there is no access to source object in the controller in maplibre.

@mariusvn
Copy link
Contributor

This issue needs more clarification and context in order to be understood and maybe resolved.

@m0nac0
Copy link
Collaborator

m0nac0 commented Nov 19, 2023

In principle, we could add a generic setSourceProperty method to MaplibreMapController, similar to the setLayerProperty method added in #303, then you could use that to update the tileUrl and reload the source (assuming that also works in the native libraries).

@m0nac0 m0nac0 changed the title Is there any way to reload the source for the added tile layer? feat: update arbitrary source properties at runtime Nov 19, 2023
@m0nac0 m0nac0 added the enhancement New feature or request label Nov 19, 2023
@m0nac0 m0nac0 changed the title feat: update arbitrary source properties at runtime Is there any way to reload the source for the added tile layer? Nov 19, 2023
@m0nac0
Copy link
Collaborator

m0nac0 commented Nov 19, 2023

I tried adding such a method, but it seems that

  • on web, there is no generic setSourceProperty method like for layer properties, instead we would need to implement/generate basically a big switch statement to set the correct properties (like we do for layer and source properties for android/iOS in LayerPropertyConverter and SourcePropertyConverter --> this would be feasible
  • on android, it seems that we can only update the url for most source types (which would suffice for your use case but not the generic method I had in mind)
  • on iOS, I can't find any way to update a source's properties, not even the url

So while the generic updateSourceProperty method I had in mind doesn't seem possible (at least right now), it may be possible able to implement

  • either a setSourceUrl method if we can find a way to set a source's url on MapLibre iOS,
  • or a refreshSource method if we find another way to force reload a source on iOS (or are willing to implement the method on iOS with just removing and re-adding the source)

@KostyaLocal
Copy link
Author

In principle, we could add a generic setSourceProperty method to MaplibreMapController, similar to the setLayerProperty method added in #303, then you could use that to update the tileUrl and reload the source (assuming that also works in the native libraries).
I'd really appreciate it. The case is very useful to redraw the map when the poi layer on the server has changed.

@l2-flutter-dev
Copy link

I'd really appreciate this as well, I'm looking for a way to update the tileUrl and this would be exactly what I need.

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

No branches or pull requests

4 participants