Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

osmdroid - display tiles bigger

I'm using osmdroid and maps downloaded from OSM up to level 16. I was wondering if there is any way I could make the osmdroid use the tile from that zoom level but draw it bigger.

The thing is that tiles on that level have enough detail for me, but are drawn to small. I've seen some other apps use the same tile levels but somehow managing to draw them bigger.

Thanks

like image 908
Filip Kis Avatar asked Aug 30 '11 08:08

Filip Kis


1 Answers

The best solution I have found to this problem (which I had myself earlier today), is to change the scaling in the tile source (I'm using my own version of OpenStreetMap):

final float scale = getBaseContext().getResources().getDisplayMetrics().density;
final int newScale = (int) (256 * scale);
String[] OSMSource = new String[2];
OSMSource[0] = "http://a.tile.openstreetmap.org/";
OSMSource[1] = "http://b.tile.openstreetmap.org/";  
XYTileSource MapSource = new XYTileSource(
        "OSM", 
        null, 
        1, 
        18, 
        newScale,
        ".png", 
        OSMSource
); 
map.setTileSource(MapSource);

Varying the scale in accordance with the screen density is a relatively good solution. During my testing some of the images became slightly blurry, but if you decrease the scaling for that contingency you get a very good outcome.

This is not my solution BTW, I found it among the OSMDROID issues on Github. Thanks goes to stefangab95.

like image 66
Steven Avatar answered Sep 28 '22 08:09

Steven