use 'max zoom level' from TileSource

This commit is contained in:
Hannes Janetzek 2013-04-24 15:41:45 +02:00
parent 923019a34a
commit e24bba1e57
4 changed files with 14 additions and 7 deletions

View File

@ -35,7 +35,7 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
final TileSource mTileSource;
public BitmapTileLayer(MapView mapView, TileSource tileSource) {
super(mapView);
super(mapView, tileSource.getZoomLevelMax());
mTileSource = tileSource;
}

View File

@ -22,6 +22,7 @@ import org.oscim.view.MapView;
public abstract class TileLayer<T extends TileLoader> extends Layer {
//private final static String TAG = TileLayer.class.getName();
private final static int MAX_ZOOMLEVEL = 17;
private boolean mClearMap = true;
@ -33,11 +34,15 @@ public abstract class TileLayer<T extends TileLoader> extends Layer {
protected final ArrayList<T> mTileLoader;
public TileLayer(MapView mapView) {
this(mapView, MAX_ZOOMLEVEL);
}
public TileLayer(MapView mapView, int maxZoom) {
super(mapView);
// TileManager responsible for adding visible tiles
// to load queue and managing in-memory tile cache.
mTileManager = new TileManager(mapView, this);
mTileManager = new TileManager(mapView, this, maxZoom);
mJobQueue = new JobQueue();

View File

@ -46,9 +46,10 @@ public class TileManager {
private static final int CACHE_TILES_MAX = 250;
static final String TAG = TileManager.class.getSimpleName();
private final static int MAX_ZOOMLEVEL = 17;
private final static int MIN_ZOOMLEVEL = 2;
private final int mMaxZoom;
// limit number tiles with new data not uploaded to GL
// TODO this should depend on the number of tiles displayed
private static final int MAX_TILES_IN_QUEUE = 40;
@ -116,10 +117,11 @@ public class TileManager {
private final float[] mBoxCoords = new float[8];
private final TileLayer<?> mTileLayer;
public TileManager(MapView mapView, TileLayer<?> tileLayer) {
public TileManager(MapView mapView, TileLayer<?> tileLayer, int maxZoom) {
mMapView = mapView;
mTileLayer = tileLayer;
mMaxZoom = maxZoom;
mMapViewPosition = mapView.getMapViewPosition();
mJobs = new ArrayList<MapTile>();
mTiles = new MapTile[CACHE_TILES_MAX];
@ -202,7 +204,7 @@ public class TileManager {
// load some tiles more than currently visible (* 0.75)
double scale = pos.scale * 0.9f;
int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, MAX_ZOOMLEVEL);
int tileZoom = FastMath.clamp(pos.zoomLevel, MIN_ZOOMLEVEL, mMaxZoom);
mMapViewPosition.getMapViewProjection(mBoxCoords);

View File

@ -23,7 +23,7 @@ public class MapQuestAerial extends AbstractTileSource {
public static final MapQuestAerial INSTANCE = new MapQuestAerial("otile1.mqcdn.com", 80);
private static final int PARALLEL_REQUESTS_LIMIT = 8;
private static final String PROTOCOL = "http";
private static final int ZOOM_LEVEL_MAX = 18;
private static final int ZOOM_LEVEL_MAX = 8;
private static final int ZOOM_LEVEL_MIN = 0;
public MapQuestAerial(String hostName, int port) {