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?
Asked
Active
Viewed 188 times
2 Answers
0
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]);

Falke Design
- 10,635
- 3
- 15
- 30
-
2OP is using Flutter, your answer is for JS. – Stefano Amorelli Dec 07 '20 at 19:52
0
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.

JaffaKetchup
- 1,151
- 10
- 26