testing tilecache for bitmap tiles
This commit is contained in:
parent
64c4c3b93c
commit
cb629744ec
@ -47,7 +47,7 @@ public class BaseMapActivity extends MapActivity {
|
|||||||
mTileSource = new OSciMap4TileSource();
|
mTileSource = new OSciMap4TileSource();
|
||||||
|
|
||||||
if (USE_CACHE) {
|
if (USE_CACHE) {
|
||||||
mCache = new TileCache(this, "cachedir", "testdb");
|
mCache = new TileCache(this, null, "tile.db");
|
||||||
mCache.setCacheSize(512 * (1 << 10));
|
mCache.setCacheSize(512 * (1 << 10));
|
||||||
mTileSource.setCache(mCache);
|
mTileSource.setCache(mCache);
|
||||||
}
|
}
|
||||||
|
@ -16,14 +16,21 @@ package org.oscim.android.test;
|
|||||||
|
|
||||||
import org.oscim.android.MapActivity;
|
import org.oscim.android.MapActivity;
|
||||||
import org.oscim.android.MapView;
|
import org.oscim.android.MapView;
|
||||||
|
import org.oscim.android.cache.TileCache;
|
||||||
import org.oscim.layers.tile.BitmapTileLayer;
|
import org.oscim.layers.tile.BitmapTileLayer;
|
||||||
import org.oscim.tiling.source.bitmap.DefaultSources.OpenStreetMap;
|
import org.oscim.tiling.source.TileSource;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class BitmapTileMapActivity extends MapActivity {
|
public class BitmapTileMapActivity extends MapActivity {
|
||||||
|
|
||||||
|
private final static boolean USE_CACHE = true;
|
||||||
|
|
||||||
MapView mMapView;
|
MapView mMapView;
|
||||||
|
|
||||||
|
private TileCache mCache;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@ -32,11 +39,22 @@ public class BitmapTileMapActivity extends MapActivity {
|
|||||||
mMapView = (MapView) findViewById(R.id.mapView);
|
mMapView = (MapView) findViewById(R.id.mapView);
|
||||||
registerMapView(mMapView);
|
registerMapView(mMapView);
|
||||||
|
|
||||||
mMap.getLayers().add(new BitmapTileLayer(mMap, new OpenStreetMap(), 20));
|
TileSource tileSource = new DefaultSources.OpenStreetMap();
|
||||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
|
|
||||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
|
if (USE_CACHE) {
|
||||||
//mMap.getLayers().add(new BitmapTileLayer(mMap, new HillShadeHD(), 20));
|
mCache = new TileCache(this, null, tileSource.getClass().getSimpleName());
|
||||||
|
mCache.setCacheSize(512 * (1 << 10));
|
||||||
|
tileSource.setCache(mCache);
|
||||||
|
}
|
||||||
|
mMap.getLayers().add(new BitmapTileLayer(mMap, tileSource));
|
||||||
|
|
||||||
mMap.setMapPosition(0, 0, 1 << 2);
|
mMap.setMapPosition(0, 0, 1 << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
if (USE_CACHE)
|
||||||
|
mCache.dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user