opensciencemap / vtm

a vector-tile map library written in java - running on android, desktop and within the browser
GNU Lesser General Public License v3.0
238 stars 176 forks source link

Tiles not loaded/reloaded with bad network connection #104

Closed stleusc closed 10 years ago

stleusc commented 10 years ago

Following scenario: You scroll around on the map but network is really bad. It will fail loading the tiles. So far so good. Now lets say you enable wifi and network is stable. To reload the tiles you either have to a) scroll around heavily to move the displayed tiles out of the queue and back in b) they will never load back since vtm is tracking some state that they were loaded even when they were not

I would like to be able to force a 'reload' of all visible tiles and tiles that would be loaded on restart of vtm. With that in place I could monitor network state and when network comes back, trigger reload.

Also: I added a feature to pause loading of some custom tiles by returning sink.completed(TILE_NOT_FOUND); in public void query(MapTile tile, ITileDataSink sink)

My current fix/workaround which I don't like is removing the layer from the map and adding it back. I'm sure there would be an easy way to clear whatever internal state is used.

Any advice is welcome. I can implement it on my own, just don't see where it's tracked.

hjanetzek commented 10 years ago

which HttpEngine are you using? OkHttps default read timeout is now 20 seconds which might be a bit too much if your tileserver is usually serving tiles faster. https://github.com/square/retrofit/issues/221

Also some mechanism to retry automatically would be nice to have..

stleusc commented 10 years ago

Well, the problem is, even automatic retry will not fix my issue if first try returned error to upper layers of VTM. I need a way to tell the upper layers that manage tile loading that all tiles in the view should be considered new. This is useful in cases where I know that my tile content has changed to force a reload.

Summary: what is a feasible way to tell VTM to request reloading all visible tiles regardless of the fact that they were loaded before.

stleusc commented 10 years ago

I assume that I need something withing the TileManager?!

hjanetzek commented 10 years ago

try mMap.clearMap() function which is used to reload all tiles when the theme was changed

stleusc commented 10 years ago

hahaha, that's funny. I just had typed clearMap() in my code when I checked my emails and saw this note ;-)

stleusc commented 10 years ago

OK, thanks! mMap.clearMap() works exactly as I need it. Now I can force a reload and I can also Monitor the devices network state and reload the tiles.