Last active
November 16, 2015 10:23
-
-
Save virtualvoid/9eac3974934e2bd55bb1 to your computer and use it in GitHub Desktop.
osmdroid density based TileSource
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sk.virtualvoid.osmdroid; | |
import android.content.Context; | |
import org.osmdroid.tileprovider.tilesource.XYTileSource; | |
/** | |
* Created by suchan_j on 16.11.2015. | |
*/ | |
public class DensityBasedTileSource { | |
private static final String key = "OSM"; | |
private static final String imageFormat = ".png"; | |
private static final Integer minZoomLevel = 1; | |
private static final Integer maxZoomLevel = 18; | |
public static XYTileSource getTileSource(Context context) { | |
final float scale = context.getResources().getDisplayMetrics().density; | |
final int newScale = (int) (256 * scale); | |
String[] osmSources = new String[] { | |
"http://a.tile.openstreetmap.org/", | |
"http://b.tile.openstreetmap.org/", | |
"http://c.tile.openstreetmap.org/" | |
}; | |
XYTileSource tileSource = new XYTileSource(key, null, minZoomLevel, maxZoomLevel, newScale, imageFormat, osmSources); | |
return tileSource; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment