p-lr / MapView

A Fast, memory efficient Android library to display tiled maps, with support for markers, paths, and rotation.
Apache License 2.0
189 stars 38 forks source link

Refresh map tiles #21

Closed aurelientymate closed 3 years ago

aurelientymate commented 3 years ago

Hi, is there a way to force refresh the map tiles. Right now, i use redrawTiles when i need a refresh. But it's only trigger a refresh on map zoom/dezoom or on map movements. So, is it possible to force redraw tiles when the function is called ? Thanks

p-lr commented 3 years ago

Hi, I'd like to better understand your need. At some point, the tiles change even when not panning or zooming, and you'd like to trigger a reload of all visible tiles. Is that correct? This is something that could be implemented in a future version.

aurelientymate commented 3 years ago

Yes, i would like to refresh all visible tiles on button click. As if on a real map, you would like to go from plan to satellite view for example.

p-lr commented 3 years ago

I see. I do the exact same thing in my own trekking app. Do do that, I destroy the existing MapView and add a new one to the view hierarchy using the same id. This way, new tiles are displayed while the new MapView has its state automatically restored using the state (zoom, pan) of the former MapView.

So, what I'm saying is: it's already possible using a not-so-handy technique. A redrawTiles() would be handy, and I'll see what I can do.

aurelientymate commented 3 years ago

I used your method, destroying the map and add a new one with the same id works for me. Thank you for your help. Great job on this lib

p-lr commented 3 years ago

@aurelientymate Hi, FYI the new 2.1.6 version has a redrawTiles() method on MapView that should work as you expect.

aurelientymate commented 3 years ago

It works perfectly, exactly what i needed. Great job ! Thanks 👍

p-lr commented 3 years ago

Thanks for the feedback!