osmdroid - display tiles bigger
Asked Answered
P

8

6

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

Peril answered 30/8, 2011 at 8:30 Comment(0)
S
3

You can't do this without modifying the source code of osmdroid. Right now, tiles are shown at their actual resolution except when the view is being animated between zoom levels. That is, the tiles are switched when the animation is done, and the scale is set to 1 again. I have tried some tricks to keep the scaling when the user tries zooming beyond the highest level of detail. It works visually, but all the functions that map from pixels to map coordinates, as well as some of the interaction when dragging the map, breaks. It would therefore require a more significant modification of the source. It is doable, but I think it's not really worth the trouble - unless you actually want to contribute the modification to the project, and do it in a less hackish way.

Shroud answered 24/11, 2011 at 9:47 Comment(0)
N
4

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.

Necessitarianism answered 10/9, 2014 at 8:38 Comment(0)
S
3

You can't do this without modifying the source code of osmdroid. Right now, tiles are shown at their actual resolution except when the view is being animated between zoom levels. That is, the tiles are switched when the animation is done, and the scale is set to 1 again. I have tried some tricks to keep the scaling when the user tries zooming beyond the highest level of detail. It works visually, but all the functions that map from pixels to map coordinates, as well as some of the interaction when dragging the map, breaks. It would therefore require a more significant modification of the source. It is doable, but I think it's not really worth the trouble - unless you actually want to contribute the modification to the project, and do it in a less hackish way.

Shroud answered 24/11, 2011 at 9:47 Comment(0)
C
3

mMapview.setTilesScaledToDpi(true)

https://github.com/osmdroid/osmdroid/blob/master/osmdroid-android/src/main/java/org/osmdroid/views/MapView.java#L307

that's should do the trick

Chromyl answered 3/1, 2016 at 13:35 Comment(0)
R
2

I'm using offline tiles and just did this to display them at 2x resolution. The important part is the 512 pixel size even though the tiles are 256.

myMapView.setTileSource  (new XYTileSource ("Mapnik", ResourceProxy.string.offline_mode, 13, 17, 512, ".png", "http://127.0.0.1"));
Rosana answered 2/11, 2013 at 23:11 Comment(2)
With a different tile size, how do osmdroid calculate the real tile coordinate?Mills
If the tiles are 256x256 and you set the tilesource as 512, it will just double the size of the tiles. I actually prefer putting Leaflet in a webview now over osmdroid.Rosana
P
1

Cloudmade have support for high-resolution tiles that look much better on the current phones on the market now. Have a look here:

http://developers.cloudmade.com/projects/tiles/documents

I would use the normal tiles for ldpi and mdpi devices, and use the high-res ones for hdpi and xhdpi devices

Peterson answered 8/6, 2012 at 11:43 Comment(1)
It seems this project is no longer maintained for small develoeprs: notes.ericjiang.com/posts/741Cyndie
G
1

To solve your problem completely, there exist two approach. The first one is that you'd generate or render map tiles by your own by mapnik-like software. The second one is using vector-based real-time renderer on mobile phone like mapsforge. The configure file or style file is the key in both of these approach.

Grouch answered 9/8, 2013 at 10:38 Comment(0)
W
0

You can use a different tile source, for instance M$ Bing. That also has bigger street names.

Wallboard answered 8/8, 2012 at 17:57 Comment(0)
D
-1

One workaround that stays within the current working model of OSMdroid is to use an image manipulation package like ImageMagick or Photoshop to create a new set of bitmap tiles at the higher zoom level.

What you need to do is take each current tile (256x256px), resize it, doubling both size and width, and then cutting the image into 4 new tiles. Save each tile according to the naming convention for the new zoom level. The tile map naming convetion is described here, as well as an easy way of getting the 4 new names from the original name

Durfee answered 22/3, 2012 at 5:16 Comment(2)
This would result in essentially replicating the tiles at the next higher zoom level.Rosana
In a sense, but it still achieves the desired result.Durfee

© 2022 - 2024 — McMap. All rights reserved.