Reputation: 106
So I'm using the flutter_map package to include openstreetmap in my app. I want my app to skip the map if it can't load it within 10 seconds, in case the internet connection is too bad. Is there a way to know if the downloading process has finished?
Upvotes: 0
Views: 559
Reputation: 1638
I know this question is very old, but this might help future readers.
Probably the easiest way to do this is implement a custom TileProvider
, following these instructions: https://docs.fleaflet.dev/plugins/making-a-plugin/creating-new-tile-providers. Then you can do whatever method of catching errors you wish inside of getImage
, and set an external flag. Bit of a workaround, but the best way to do it.
Upvotes: 0
Reputation: 11348
You can listen on the load
event on the map, it is fired when the map is loaded load map event or check if the TileLayer is loaded load tile event
To check on the map load
event you have to add the listener before you call setView
var map = L.map('map');
map.on('load', (e)=>console.log(e));
map.setView([0,0]);
Upvotes: 0