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
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.
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.
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
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"));
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
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.
You can use a different tile source, for instance M$ Bing. That also has bigger street names.
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
精彩评论