add cache for S3DB layer
This commit is contained in:
parent
feeebae5fb
commit
e52bed199a
@ -30,7 +30,7 @@ import android.view.MenuItem;
|
||||
|
||||
public class BaseMapActivity extends MapActivity {
|
||||
|
||||
private final static boolean USE_CACHE = true;
|
||||
final static boolean USE_CACHE = true;
|
||||
|
||||
MapView mMapView;
|
||||
VectorTileLayer mBaseLayer;
|
||||
@ -70,7 +70,7 @@ public class BaseMapActivity extends MapActivity {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (USE_CACHE)
|
||||
if (mCache != null)
|
||||
mCache.dispose();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.oscim.android.test;
|
||||
|
||||
import org.oscim.android.cache.TileCache;
|
||||
import org.oscim.layers.tile.s3db.S3DBLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
@ -10,6 +11,8 @@ import android.os.Bundle;
|
||||
|
||||
public class S3DBMapActivity extends BaseMapActivity {
|
||||
|
||||
TileCache mS3dbCache;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -19,9 +22,24 @@ public class S3DBMapActivity extends BaseMapActivity {
|
||||
//mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
|
||||
TileSource ts = new OSciMap4TileSource("http://opensciencemap.org/tiles/s3db");
|
||||
mMap.layers().add(new S3DBLayer(mMap, ts));
|
||||
|
||||
if (USE_CACHE) {
|
||||
mS3dbCache = new TileCache(this, null, "s3db.db");
|
||||
mS3dbCache.setCacheSize(512 * (1 << 10));
|
||||
ts.setCache(mS3dbCache);
|
||||
}
|
||||
|
||||
mMap.layers().add(new S3DBLayer(mMap, ts));
|
||||
mMap.layers().add(new LabelLayer(mMap, mBaseLayer));
|
||||
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 14));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
if (mS3dbCache != null)
|
||||
mS3dbCache.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user