android example: use StamenToner bitmaps

This commit is contained in:
Hannes Janetzek 2014-01-29 19:26:57 +01:00
parent 50d9481d73
commit a828007c89
4 changed files with 30 additions and 29 deletions

View File

@ -10,7 +10,7 @@
<uses-sdk
android:minSdkVersion="10"
android:targetSdkVersion="18" />
android:targetSdkVersion="10" />
<application
android:allowBackup="true"

View File

@ -26,6 +26,15 @@ import android.os.Bundle;
public class BitmapTileMapActivity extends MapActivity {
private final static boolean USE_CACHE = true;
private final TileSource mTileSource;
public BitmapTileMapActivity() {
mTileSource = new DefaultSources.OpenStreetMap();
}
public BitmapTileMapActivity(TileSource tileSource) {
mTileSource = tileSource;
}
MapView mMapView;
@ -39,14 +48,12 @@ public class BitmapTileMapActivity extends MapActivity {
mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);
TileSource tileSource = new DefaultSources.OpenStreetMap();
if (USE_CACHE) {
mCache = new TileCache(this, null, tileSource.getClass().getSimpleName());
mCache = new TileCache(this, null, mTileSource.getClass().getSimpleName());
mCache.setCacheSize(512 * (1 << 10));
tileSource.setCache(mCache);
mTileSource.setCache(mCache);
}
mMap.getLayers().add(new BitmapTileLayer(mMap, tileSource));
mMap.getLayers().add(new BitmapTileLayer(mMap, mTileSource));
mMap.setMapPosition(0, 0, 1 << 2);
}

View File

@ -19,8 +19,6 @@ package org.oscim.android.test;
import java.util.ArrayList;
import java.util.List;
import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.android.canvas.AndroidGraphics;
import org.oscim.core.GeoPoint;
import org.oscim.layers.TileGridLayer;
@ -29,21 +27,22 @@ import org.oscim.layers.marker.ItemizedIconLayer.OnItemGestureListener;
import org.oscim.layers.marker.MarkerItem;
import org.oscim.layers.marker.MarkerItem.HotspotPlace;
import org.oscim.layers.marker.MarkerSymbol;
import org.oscim.tiling.source.bitmap.DefaultSources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.Toast;
public class MarkerOverlayActivity extends MapActivity implements OnItemGestureListener<MarkerItem> {
MapView mMapView;
public class MarkerOverlayActivity extends BitmapTileMapActivity
implements OnItemGestureListener<MarkerItem> {
public MarkerOverlayActivity() {
super(new DefaultSources.StamenToner());
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);
Drawable d = getResources().getDrawable(R.drawable.marker_poi);
MarkerSymbol symbol = AndroidGraphics.makeMarker(d, HotspotPlace.CENTER);

View File

@ -19,25 +19,22 @@ package org.oscim.android.test;
import java.util.ArrayList;
import java.util.List;
import org.oscim.android.MapActivity;
import org.oscim.android.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.core.GeoPoint;
import org.oscim.layers.PathLayer;
import org.oscim.tiling.source.bitmap.DefaultSources;
import android.os.Bundle;
public class PathOverlayActivity extends MapActivity {
public class PathOverlayActivity extends BitmapTileMapActivity {
MapView mMapView;
public PathOverlayActivity() {
super(new DefaultSources.StamenToner());
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
mMapView = (MapView) findViewById(R.id.mapView);
registerMapView(mMapView);
for (double lon = -180; lon < 180; lon += 5) {
List<GeoPoint> pts = new ArrayList<GeoPoint>();
@ -46,9 +43,8 @@ public class PathOverlayActivity extends MapActivity {
//pts.add(new GeoPoint(lat, lon));
pts.add(new GeoPoint(lat, Math.sin((lat + 180) / 360 * Math.PI) * lon));
PathLayer pathLayer = new PathLayer(mMap,
Color.rainbow((float) (lon + 180) / 360),
3);
int c = Color.fade(Color.rainbow((float) (lon + 180) / 360), 0.8f);
PathLayer pathLayer = new PathLayer(mMap, c, 3);
pathLayer.setPoints(pts);
mMap.getLayers().add(pathLayer);
@ -61,9 +57,8 @@ public class PathOverlayActivity extends MapActivity {
//pts.add(new GeoPoint(lat, lon));
pts.add(new GeoPoint(Math.sin(lon / 6 * Math.PI) * 3 + lat, lon));
PathLayer pathLayer = new PathLayer(mMap,
Color.rainbow((float) (lat + 90) / 180),
3);
int c = Color.fade(Color.rainbow((float) (lat + 90) / 180), 0.8f);
PathLayer pathLayer = new PathLayer(mMap, c, 3);
pathLayer.setPoints(pts);
mMap.getLayers().add(pathLayer);