android example: use StamenToner bitmaps
This commit is contained in:
parent
50d9481d73
commit
a828007c89
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<uses-sdk
|
<uses-sdk
|
||||||
android:minSdkVersion="10"
|
android:minSdkVersion="10"
|
||||||
android:targetSdkVersion="18" />
|
android:targetSdkVersion="10" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
|
@ -26,6 +26,15 @@ import android.os.Bundle;
|
|||||||
public class BitmapTileMapActivity extends MapActivity {
|
public class BitmapTileMapActivity extends MapActivity {
|
||||||
|
|
||||||
private final static boolean USE_CACHE = true;
|
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;
|
MapView mMapView;
|
||||||
|
|
||||||
@ -39,14 +48,12 @@ public class BitmapTileMapActivity extends MapActivity {
|
|||||||
mMapView = (MapView) findViewById(R.id.mapView);
|
mMapView = (MapView) findViewById(R.id.mapView);
|
||||||
registerMapView(mMapView);
|
registerMapView(mMapView);
|
||||||
|
|
||||||
TileSource tileSource = new DefaultSources.OpenStreetMap();
|
|
||||||
|
|
||||||
if (USE_CACHE) {
|
if (USE_CACHE) {
|
||||||
mCache = new TileCache(this, null, tileSource.getClass().getSimpleName());
|
mCache = new TileCache(this, null, mTileSource.getClass().getSimpleName());
|
||||||
mCache.setCacheSize(512 * (1 << 10));
|
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);
|
mMap.setMapPosition(0, 0, 1 << 2);
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ package org.oscim.android.test;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.oscim.android.MapActivity;
|
|
||||||
import org.oscim.android.MapView;
|
|
||||||
import org.oscim.android.canvas.AndroidGraphics;
|
import org.oscim.android.canvas.AndroidGraphics;
|
||||||
import org.oscim.core.GeoPoint;
|
import org.oscim.core.GeoPoint;
|
||||||
import org.oscim.layers.TileGridLayer;
|
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;
|
||||||
import org.oscim.layers.marker.MarkerItem.HotspotPlace;
|
import org.oscim.layers.marker.MarkerItem.HotspotPlace;
|
||||||
import org.oscim.layers.marker.MarkerSymbol;
|
import org.oscim.layers.marker.MarkerSymbol;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||||
|
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class MarkerOverlayActivity extends MapActivity implements OnItemGestureListener<MarkerItem> {
|
public class MarkerOverlayActivity extends BitmapTileMapActivity
|
||||||
MapView mMapView;
|
implements OnItemGestureListener<MarkerItem> {
|
||||||
|
|
||||||
|
public MarkerOverlayActivity() {
|
||||||
|
super(new DefaultSources.StamenToner());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(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);
|
Drawable d = getResources().getDrawable(R.drawable.marker_poi);
|
||||||
MarkerSymbol symbol = AndroidGraphics.makeMarker(d, HotspotPlace.CENTER);
|
MarkerSymbol symbol = AndroidGraphics.makeMarker(d, HotspotPlace.CENTER);
|
||||||
|
@ -19,25 +19,22 @@ package org.oscim.android.test;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.oscim.android.MapActivity;
|
|
||||||
import org.oscim.android.MapView;
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.core.GeoPoint;
|
import org.oscim.core.GeoPoint;
|
||||||
import org.oscim.layers.PathLayer;
|
import org.oscim.layers.PathLayer;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
public class PathOverlayActivity extends MapActivity {
|
public class PathOverlayActivity extends BitmapTileMapActivity {
|
||||||
|
|
||||||
MapView mMapView;
|
public PathOverlayActivity() {
|
||||||
|
super(new DefaultSources.StamenToner());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(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) {
|
for (double lon = -180; lon < 180; lon += 5) {
|
||||||
List<GeoPoint> pts = new ArrayList<GeoPoint>();
|
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, lon));
|
||||||
pts.add(new GeoPoint(lat, Math.sin((lat + 180) / 360 * Math.PI) * lon));
|
pts.add(new GeoPoint(lat, Math.sin((lat + 180) / 360 * Math.PI) * lon));
|
||||||
|
|
||||||
PathLayer pathLayer = new PathLayer(mMap,
|
int c = Color.fade(Color.rainbow((float) (lon + 180) / 360), 0.8f);
|
||||||
Color.rainbow((float) (lon + 180) / 360),
|
PathLayer pathLayer = new PathLayer(mMap, c, 3);
|
||||||
3);
|
|
||||||
pathLayer.setPoints(pts);
|
pathLayer.setPoints(pts);
|
||||||
|
|
||||||
mMap.getLayers().add(pathLayer);
|
mMap.getLayers().add(pathLayer);
|
||||||
@ -59,11 +55,10 @@ public class PathOverlayActivity extends MapActivity {
|
|||||||
|
|
||||||
for (double lon = -180; lon <= 180; lon += 1)
|
for (double lon = -180; lon <= 180; lon += 1)
|
||||||
//pts.add(new GeoPoint(lat, lon));
|
//pts.add(new GeoPoint(lat, lon));
|
||||||
pts.add(new GeoPoint(Math.sin(lon/6 * Math.PI) * 3 + lat, lon));
|
pts.add(new GeoPoint(Math.sin(lon / 6 * Math.PI) * 3 + lat, lon));
|
||||||
|
|
||||||
PathLayer pathLayer = new PathLayer(mMap,
|
int c = Color.fade(Color.rainbow((float) (lat + 90) / 180), 0.8f);
|
||||||
Color.rainbow((float) (lat + 90) / 180),
|
PathLayer pathLayer = new PathLayer(mMap, c, 3);
|
||||||
3);
|
|
||||||
pathLayer.setPoints(pts);
|
pathLayer.setPoints(pts);
|
||||||
|
|
||||||
mMap.getLayers().add(pathLayer);
|
mMap.getLayers().add(pathLayer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user