-
Notifications
You must be signed in to change notification settings - Fork 61
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
urlTemplate does not get updated with setState #27
Comments
Jan, thanks for the issue. So far, this plugin hasn't been designed to support your use-case (changing provider URLs.) There are a couple of things that are likely going wrong here:
There's a chance that you can get it to work if you change the theme ID and the IDs of providers in the theme, including the IDs passed to TileProviders. By changing the theme ID, you'll cause the layer to re-initialize, and by changing the IDs of the providers referenced in the theme, you'll get different cache keys (filenames) for the cached tiles so that the cache doesn't load tiles from the wrong provider. Let me know how it works out. |
Closing, but would love to know if it worked out for you. |
Oh, I'm sorry, I forgot to respond. I don't actually need the switching ability in my app, I just encountered the issue when prototyping and playing around with various map sources. Knowing this is the intended behaviour, I'm ok with it. |
I ran into an issue that when I
setState
on my stateful widget (which containsFlutterMap
which uses a vector tile layer). I have the url template stored in a variable which can change (e.g. different tile providers). However, when I change the url template insetState
, theNetworkVectorTileProvider
still uses the old url.Example
It is identical to the example provided in this repo except for a few changes:
_MyHomePageState
:urlGood
is a working url templateurlBad
is a non-working url templategood
is a switch choosing one of those urls_urlTemplate
returns one of the two urls based on the value ofgood
If the app is started with
good = false
, the map does not load the tiles, which is correct. When I tap the button, the url should switch, which it does as indicated by the change of the app bar title, but the map tiles still don't load. To make the change, I need to change it togood = true
in the code and (hot)restart the app.Source code (my stadiamaps api key redacted):
The text was updated successfully, but these errors were encountered: