Closed danwelch3 closed 1 month ago
the issue here is the local var for the tile provider zoomLevelMax
and the MapView maxZoomLevel
are tied together
setting the MapView max also sets the tile provider max to 20.0, which can throw errors downloading offline maps
to separate them you can set a fixed maxZoomLevel = 20.0 then then set zoomLevelMax
in loadOnlineTileSourceBase() instead of map.maxZoomLevel
@andrekir I see your point. Thanks. I addressed it by resetting the max map zoom when the "Download Region" is selected to the map source's max. This has the benefit of zooming back out for the user and feels more user friendly to me. Once the Cancel button is hit to close the download dialog, it re-applies the 20 or higher max zoom.
FYI, I'm using the coerceAtLeast to set 20 or higher because OSMDroid supports >20 on source layers.
to separate them this line needs to be removed:
coerceAtLeast(20.0) will always return 20.0, so just set maxZoomLevel
to 20.0 (same as minZoomLevel
)
then set the local var zoomLevelMax
directly from the tile provider in loadOnlineTileSourceBase()
I made the changes you advised, but in testing found that the CacheManager
call was now receiving 0.0 as the zoomLevelMax
due to the it being reinitialized after loadOnlineTileSourceBase()
runs.
https://github.com/meshtastic/Meshtastic-Android/blob/f689d772d62bf0bb7adc1ae27cb5fe77ca794136/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt#L534
I moved zoomLevelMin
and zoomLevelMax
outside the MapView
function to avoid them being reinitialized.
Also changed this line, as it's reference to zoomLevelDouble
could set the min level to a greater value than the max.
https://github.com/meshtastic/Meshtastic-Android/blob/f689d772d62bf0bb7adc1ae27cb5fe77ca794136/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt#L523
I set it to the source layers min zoom level to ensure that cached regions have smooth zooming at all levels.
I went ahead and made the necessary changes in https://github.com/meshtastic/Meshtastic-Android/commit/be6ea79c04e81463716d7fce52f29ea9878793f1. could you test it out and confirm it's working? thanks for the effort and let me know if you have any questions.
Yes, that looks like it works. I don't have a lot of Kotlin/Java experience, so seeing the remember
API used in place of what I did was much cleaner.
https://github.com/meshtastic/Meshtastic-Android/blob/be6ea79c04e81463716d7fce52f29ea9878793f1/app/src/main/java/com/geeksville/mesh/ui/map/MapFragment.kt#L278-L279
I still think there some benefit to zooming out to the source max when initiating a download, so the user is shown a realistic view of what is being cached.
good to hear it's working. this part of the code is a unique mix for sure, and can be tricky to navigate. let's keep it simple, most users don't zoom all the way in to select areas for download.
I'm going to close this now that it's sorted out.
Resolves #926 When nodes are located close together, some of the map layers do not zoom in enough to view markers without overlapping. This sets the max zoom level to at least 20.