Search code examples
javaandroidosmdroidmobile-application

Android Mapview Zoom Level - Custom Tile Server


I created an Android Mobile Application which uses OSMDroid Mapview. It loads perfectly fine from zoom levels below 18. However it only rescales and never serves me tiles from 19 and below.

I have my own tile server using Mapnik, Renderd, Mod_tile so on and so forth. I've set my application to use my own tile server too. Using .../osm_tiles/{zoom}/{x}/{y} I know it goes down to level 20, as I've set. It simply doesn't serve it to my mobile device.

I notice that after a while, the tiles cached on my mobile phone tends to "mix" with some loaded with the default MAPNIK one. Which is causing my map to look weird in certain places.

EDIT: Thanks for all who gave me tips and advice. After deleting and re-downloading the tiles, it's no longer mixed! I didn't see any mixing of names when I looked through my code but I'm pretty sure at some point I must've made the mistake of naming them the same.

It however, still doesn't go below level 18. Here's what I set in my code though:

ITileSource tileSource;
tileSource = new XYTileSource("custom", ResourceProxy.string.mapnik, 16, 20, 256, ".png", custom);
    TileSourceFactory.addTileSource(tileSource);

The tiles do go down to 20 upon checking, mod_tile serves them when I access it from the web browser. Looking through the Android Monitor (Using Android Studios Preview 4) I see it downloading and fetching tiles at higher levels but as soon as it goes down to 19, all that stops fetching.


Solution

  • Firstly, solved the issue of the mixed tiles by deleting and re-downloading the tiles, it's no longer mixed! I didn't see any mixing of names when I looked through my code but I'm pretty sure at some point I must've made the mistake of naming them the same. Thanks to Spy for pointing it out.

    So just plug in the your android phone, look for the folder named "osmdroid" and delete tiles accordingly.

    Next, it seems I had forgotten to add the line

    mv.setTileSource(TileSourceFactory.getTileSource("private"));
    

    After creating the source and adding it, I need to also set it on my mapview specifically. It previously wasn't going past level 18 and downloading tiles because it was using the default OSM tile source! :)