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

onStyleLoadedCallback invoked multiple times #330

Closed
AAverin opened this issue Jun 13, 2020 · 8 comments
Closed

onStyleLoadedCallback invoked multiple times #330

AAverin opened this issue Jun 13, 2020 · 8 comments

Comments

@AAverin
Copy link
Contributor

AAverin commented Jun 13, 2020

Is there a guarantee that onStyleLoadedCallback will be invoked only once to indicate that the map is ready or it can be invoked multiple times?
At the moment it gets invoked 7 times for me when map is created and I can't understand why.

@m0nac0
Copy link
Collaborator

m0nac0 commented Jun 13, 2020

@AAverin On what platform and with which kind of style are you experiencing this? I'd expect it to be only invoked once but as far as I know that's not something we explicitly guarantee.

@andrea689
Copy link
Collaborator

This callback is called every time you change the map style and this is been loaded

@AAverin
Copy link
Contributor Author

AAverin commented Jun 13, 2020

@m0nac0 on android, will need to check on ios.
I am not changing my map style and just using mapbox streets on map init

@AAverin
Copy link
Contributor Author

AAverin commented Jun 14, 2020

OK, I have found what's the problem.
SDK is fine, problem is that I am using navigator to replace a route and looks like MapBox instance stays alive in the Route that there before and they pile up with new routes replacements.

This kind of brings me back to #245
What would be the right way to do this?

My use case. I have lots of markers on the map and I want to have a route in the app that will open the map tab and focus on a specific marker. I should be able to do this from any screen, which is why I am now using Navigator.

@AAverin
Copy link
Contributor Author

AAverin commented Jun 14, 2020

Same problem happens if I just have multiple different maps on different screens.
I leave the screen, go to another one with a map, but the old map instance is still alive, it seems.
There at least should be a way to destroy mapbox properly.

@AAverin
Copy link
Contributor Author

AAverin commented Jun 14, 2020

Looks like added markers also persist between different maps as if either nothing was destroyed or there is indeed a single map in the background and I should expect this on the flutter side when using multiple maps - clear map instance between screens, expect multiple calls to onMapCreated and onStyleLoaded.

Anything else to expect?

@andrea689
Copy link
Collaborator

andrea689 commented Jun 14, 2020

#315 should fix it

Try to use master branch

@AAverin
Copy link
Contributor Author

AAverin commented Jun 14, 2020

@andrea689 Indeed, works great on master, no longer multiple callbacks and markers are also working per map instance.
Thanks

@AAverin AAverin closed this as completed Jun 14, 2020
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