Meshtastic-Android icon indicating copy to clipboard operation
Meshtastic-Android copied to clipboard

[Improvement] View maps a zoom beyond tile max zoom

Open danwelch3 opened this issue 1 year ago • 3 comments

Background: When multiple nodes are close by each other their markers on the map overlap and some are not visible at some zoom levels. I find this most often on the USGS Topo layer which only zooms to 15. Since this is one of the few downloadable layers, it's not easily remedied.

Details: When submitting a PR to increase the max zoom of the USGS Topo layer, I was informed that the USGS tile server doesn't work >15. When looking into this I found that their map server spec specifies zoom levels up to 23, but in testing anything with a z of 16 and below seems to work just fine within the US (areas outside the US are max 12. (Side note, if anyone can give me more info on why it's limited to 15 instead of 16, I'd like to know)

Just for reference, here's an example tile at z=16 https://basemap.nationalmap.gov/arcgis/rest/services/USGSTopo/MapServer/tile/16/24567/13229

It looks like osmdroid supports zooming further than the max tile zoom. This can be seen in their demo app under the "Zoom Restricted Online Tiles" sample. Is there interest in decoupling the max view zoom from the max layer tile zoom? If so, I will work on a new PR.

danwelch3 avatar Mar 20 '24 23:03 danwelch3

the maximum zoom level of an osmdroid MapView is set using the maxZoomLevel property

andrekir avatar Mar 21 '24 11:03 andrekir

Exactly. This can be accomplished by changing line 509 in MapFragment.kt as follows.


    fun loadOnlineTileSourceBase(): ITileSource {
        val id = mPrefs.getInt(mapStyleId, 0)
        debug("mapStyleId from prefs: $id")
        return CustomTileSource.getTileSource(id).also {
            map.maxZoomLevel = it.maximumZoomLevel.toDouble()
            map.maxZoomLevel = it.maximumZoomLevel.coerceAtLeast(20).toDouble()
            showDownloadButton =
                if (it is OnlineTileSourceBase) it.tileSourcePolicy.acceptsBulkDownload() else false
        }
    }

This has the added benefit of not changing zoom as drastically when switching between maps. If this seems like a change worth making, I will submit the PR.

danwelch3 avatar Mar 21 '24 17:03 danwelch3

This used to be like this in 2.1.x app IIRC....

eldoctorcool avatar Mar 25 '24 04:03 eldoctorcool

completed in https://github.com/meshtastic/Meshtastic-Android/commit/be6ea79c04e81463716d7fce52f29ea9878793f1

andrekir avatar Oct 06 '24 08:10 andrekir