remove TileSource from GdxMap constructor
This commit is contained in:
parent
b433ca6dff
commit
f82ee186d0
@ -8,7 +8,7 @@ import org.oscim.backend.GLAdapter;
|
|||||||
import org.oscim.backend.Log;
|
import org.oscim.backend.Log;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.tilesource.TileSource;
|
import org.oscim.tilesource.TileSource;
|
||||||
import org.oscim.tilesource.oscimap4.OSciMap4TileSource;
|
import org.oscim.tilesource.oscimap2.OSciMap2TileSource;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
@ -26,10 +26,11 @@ public class MainActivity extends AndroidApplication {
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// set our globals
|
// set globals
|
||||||
CanvasAdapter.g = AndroidGraphics.INSTANCE;
|
CanvasAdapter.g = AndroidGraphics.INSTANCE;
|
||||||
GLAdapter.g = new AndroidGLAdapter();
|
GLAdapter.g = new AndroidGLAdapter();
|
||||||
Log.logger = new AndroidLog();
|
Log.logger = new AndroidLog();
|
||||||
|
|
||||||
// TODO make this dpi dependent
|
// TODO make this dpi dependent
|
||||||
Tile.SIZE = 400;
|
Tile.SIZE = 400;
|
||||||
|
|
||||||
@ -38,9 +39,22 @@ public class MainActivity extends AndroidApplication {
|
|||||||
|
|
||||||
new SharedLibraryLoader().load("vtm-jni");
|
new SharedLibraryLoader().load("vtm-jni");
|
||||||
|
|
||||||
TileSource tileSource = new OSciMap4TileSource();
|
initialize(new GdxMapAndroid(), cfg);
|
||||||
tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing");
|
|
||||||
|
|
||||||
initialize(new GdxMap(tileSource), cfg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GdxMapAndroid extends GdxMap{
|
||||||
|
@Override
|
||||||
|
public void create() {
|
||||||
|
super.create();
|
||||||
|
|
||||||
|
//TileSource ts = new OSciMap4TileSource();
|
||||||
|
//ts.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing");
|
||||||
|
|
||||||
|
TileSource ts = new OSciMap2TileSource();
|
||||||
|
ts.setOption("url", "http://city.informatik.uni-bremen.de/osci/map-live");
|
||||||
|
|
||||||
|
initDefaultMap(ts, true, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
@ -4,10 +4,8 @@ import org.oscim.awt.AwtGraphics;
|
|||||||
import org.oscim.backend.CanvasAdapter;
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.layers.overlay.GenericOverlay;
|
|
||||||
import org.oscim.renderer.layers.GridRenderLayer;
|
|
||||||
import org.oscim.tilesource.TileSource;
|
import org.oscim.tilesource.TileSource;
|
||||||
import org.oscim.tilesource.oscimap2.OSciMap2TileSource;
|
import org.oscim.tilesource.oscimap4.OSciMap4TileSource;
|
||||||
|
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
|
||||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
|
||||||
@ -28,31 +26,29 @@ public class Main {
|
|||||||
// set our globals
|
// set our globals
|
||||||
CanvasAdapter.g = AwtGraphics.INSTANCE;
|
CanvasAdapter.g = AwtGraphics.INSTANCE;
|
||||||
GLAdapter.g = new GdxGLAdapter();
|
GLAdapter.g = new GdxGLAdapter();
|
||||||
Tile.SIZE = 256;
|
GLAdapter.GDX_DESKTOP_QUIRKS = true;
|
||||||
|
|
||||||
|
Tile.SIZE = 360;
|
||||||
|
|
||||||
new SharedLibraryLoader().load("vtm-jni");
|
new SharedLibraryLoader().load("vtm-jni");
|
||||||
|
|
||||||
//TileSource tileSource = new OSciMap4TileSource();
|
new LwjglApplication(new GdxMapDesktop(), cfg);
|
||||||
//tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/testing-nocache");
|
|
||||||
|
|
||||||
TileSource tileSource = new OSciMap2TileSource();
|
|
||||||
tileSource.setOption("url", "http://city.informatik.uni-bremen.de/osci/map-live");
|
|
||||||
|
|
||||||
new LwjglApplication(new GdxMapDesktop(tileSource), cfg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static class GdxMapDesktop extends GdxMap{
|
static class GdxMapDesktop extends GdxMap {
|
||||||
|
|
||||||
public GdxMapDesktop(TileSource tileSource) {
|
public GdxMapDesktop() {
|
||||||
super(tileSource);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
super.create();
|
super.create();
|
||||||
|
|
||||||
//mMapView.getLayerManager().add(new BitmapTileLayer(mMapView, ArcGISWorldShaded.INSTANCE));
|
TileSource tileSource = new OSciMap4TileSource();
|
||||||
//mMapView.getLayerManager().add(new GenericOverlay(mMapView, new GridRenderLayer(mMapView)));
|
tileSource.setOption("url", "http://city.informatik.uni-bremen.de/tiles/vtm");
|
||||||
|
|
||||||
|
initDefaultMap(tileSource, false, true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,7 @@ public class GwtLauncher extends GwtApplication {
|
|||||||
else
|
else
|
||||||
Tile.SIZE = 360;
|
Tile.SIZE = 360;
|
||||||
|
|
||||||
String url = getMapConfig("tileurl");
|
return new GwtGdxMap();
|
||||||
|
|
||||||
TileSource tileSource;
|
|
||||||
if ("oscimap4".equals(getMapConfig("tilesource")))
|
|
||||||
tileSource = new OSciMap4TileSource();
|
|
||||||
else
|
|
||||||
tileSource = new OSciMap2TileSource();
|
|
||||||
|
|
||||||
tileSource.setOption("url", url);
|
|
||||||
return new GwtGdxMap(tileSource);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native String getMapConfig(String key)/*-{
|
private static native String getMapConfig(String key)/*-{
|
||||||
@ -55,10 +46,6 @@ public class GwtLauncher extends GwtApplication {
|
|||||||
|
|
||||||
class GwtGdxMap extends GdxMap {
|
class GwtGdxMap extends GdxMap {
|
||||||
|
|
||||||
public GwtGdxMap(TileSource tileSource) {
|
|
||||||
super(tileSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
CanvasAdapter.g = GwtCanvasAdapter.INSTANCE;
|
CanvasAdapter.g = GwtCanvasAdapter.INSTANCE;
|
||||||
@ -78,6 +65,17 @@ public class GwtLauncher extends GwtApplication {
|
|||||||
p.setZoomLevel(zoom);
|
p.setZoomLevel(zoom);
|
||||||
p.setPosition(lat, lon);
|
p.setPosition(lat, lon);
|
||||||
mMapView.setMapPosition(p);
|
mMapView.setMapPosition(p);
|
||||||
|
|
||||||
|
|
||||||
|
String url = getMapConfig("tileurl");
|
||||||
|
TileSource tileSource;
|
||||||
|
if ("oscimap4".equals(getMapConfig("tilesource")))
|
||||||
|
tileSource = new OSciMap4TileSource();
|
||||||
|
else
|
||||||
|
tileSource = new OSciMap2TileSource();
|
||||||
|
|
||||||
|
tileSource.setOption("url", url);
|
||||||
|
mMapView.setBaseMap(tileSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.layers.labeling.LabelLayer;
|
import org.oscim.layers.labeling.LabelLayer;
|
||||||
import org.oscim.layers.overlay.BuildingOverlay;
|
import org.oscim.layers.overlay.BuildingOverlay;
|
||||||
|
import org.oscim.layers.overlay.GenericOverlay;
|
||||||
import org.oscim.layers.tile.vector.MapTileLayer;
|
import org.oscim.layers.tile.vector.MapTileLayer;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.GLState;
|
import org.oscim.renderer.GLState;
|
||||||
|
import org.oscim.renderer.layers.GridRenderLayer;
|
||||||
import org.oscim.theme.InternalRenderTheme;
|
import org.oscim.theme.InternalRenderTheme;
|
||||||
import org.oscim.tilesource.TileSource;
|
import org.oscim.tilesource.TileSource;
|
||||||
import org.oscim.view.MapView;
|
import org.oscim.view.MapView;
|
||||||
@ -31,13 +33,11 @@ public class GdxMap implements ApplicationListener {
|
|||||||
|
|
||||||
protected final MapView mMapView;
|
protected final MapView mMapView;
|
||||||
private final GLRenderer mMapRenderer;
|
private final GLRenderer mMapRenderer;
|
||||||
private final TileSource mTileSource;
|
|
||||||
|
|
||||||
boolean mRenderRequest;
|
boolean mRenderRequest;
|
||||||
|
|
||||||
public GdxMap(TileSource tileSource) {
|
public GdxMap() {
|
||||||
AssetAdapter.g = new GdxAssetAdapter();
|
AssetAdapter.g = new GdxAssetAdapter();
|
||||||
mTileSource = tileSource;
|
|
||||||
|
|
||||||
mMapView = new MapView() {
|
mMapView = new MapView() {
|
||||||
@Override
|
@Override
|
||||||
@ -75,11 +75,12 @@ public class GdxMap implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean postDelayed(final Runnable action, long delay) {
|
public boolean postDelayed(final Runnable action, long delay) {
|
||||||
Timer.schedule(new Task(){
|
Timer.schedule(new Task() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
action.run();
|
action.run();
|
||||||
}}, delay / 1000f);
|
}
|
||||||
|
}, delay / 1000f);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -88,10 +89,33 @@ public class GdxMap implements ApplicationListener {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void initDefaultMap(TileSource tileSource, boolean tileGrid, boolean labels,
|
||||||
|
boolean buildings) {
|
||||||
|
|
||||||
|
if (tileSource != null) {
|
||||||
|
mMapLayer = mMapView.setBaseMap(tileSource);
|
||||||
|
mMapView.setTheme(InternalRenderTheme.DEFAULT);
|
||||||
|
|
||||||
|
if (buildings)
|
||||||
|
mMapView.getLayerManager().add(
|
||||||
|
new BuildingOverlay(mMapView, mMapLayer.getTileLayer()));
|
||||||
|
|
||||||
|
if (labels)
|
||||||
|
mMapView.getLayerManager().add(new LabelLayer(mMapView,
|
||||||
|
mMapLayer.getTileLayer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tileGrid)
|
||||||
|
mMapView.getLayerManager().add(new GenericOverlay(mMapView,
|
||||||
|
new GridRenderLayer(mMapView)));
|
||||||
|
}
|
||||||
|
|
||||||
// Stage ui;
|
// Stage ui;
|
||||||
// Label fps;
|
// Label fps;
|
||||||
// BitmapFont font;
|
// BitmapFont font;
|
||||||
|
|
||||||
MapTileLayer mMapLayer;
|
MapTileLayer mMapLayer;
|
||||||
|
GenericOverlay mGridLayer;
|
||||||
|
|
||||||
int mHeight, mWidth;
|
int mHeight, mWidth;
|
||||||
|
|
||||||
@ -108,39 +132,11 @@ public class GdxMap implements ApplicationListener {
|
|||||||
mWidth = w;
|
mWidth = w;
|
||||||
mHeight = h;
|
mHeight = h;
|
||||||
|
|
||||||
if (mTileSource != null) {
|
|
||||||
//TileSource tileSource = new OSciMap2TileSource();
|
|
||||||
//tileSource.setOption("url",
|
|
||||||
// "http://city.informatik.uni-bremen.de/osci/map-live");
|
|
||||||
|
|
||||||
// TileSource tileSource = new OSciMap4TileSource();
|
|
||||||
// tileSource.setOption("url",
|
|
||||||
// "http://city.informatik.uni-bremen.de/osci/testing");
|
|
||||||
|
|
||||||
// TileSource tileSource = new TestTileSource();
|
|
||||||
|
|
||||||
mMapLayer = mMapView.setBaseMap(mTileSource);
|
|
||||||
mMapView.setTheme(InternalRenderTheme.DEFAULT);
|
|
||||||
|
|
||||||
mMapView.getLayerManager().add(new BuildingOverlay(mMapView, mMapLayer.getTileLayer()));
|
|
||||||
mMapView.getLayerManager().add(new LabelLayer(mMapView, mMapLayer.getTileLayer()));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//mMapView.setBackgroundMap(new BitmapTileLayer(mMapView,
|
|
||||||
// ArcGISWorldShaded.INSTANCE));
|
|
||||||
|
|
||||||
//mMapView.setBackgroundMap(new BitmapTileLayer(mMapView,
|
|
||||||
// OpenStreetMapMapnik.INSTANCE));
|
|
||||||
|
|
||||||
//mMapView.getLayerManager().add(new GenericOverlay(mMapView, new
|
|
||||||
// GridRenderLayer(mMapView)));
|
|
||||||
|
|
||||||
mMapView.getMapViewPosition().setViewport(w, h);
|
mMapView.getMapViewPosition().setViewport(w, h);
|
||||||
MapPosition p = new MapPosition();
|
MapPosition p = new MapPosition();
|
||||||
p.setZoomLevel(3);
|
p.setZoomLevel(14);
|
||||||
//p.setPosition(53.08, 8.83);
|
p.setPosition(53.08, 8.83);
|
||||||
p.setPosition(0.0, 0.0);
|
//p.setPosition(0.0, 0.0);
|
||||||
mMapView.setMapPosition(p);
|
mMapView.setMapPosition(p);
|
||||||
|
|
||||||
mMapRenderer.onSurfaceCreated();
|
mMapRenderer.onSurfaceCreated();
|
||||||
@ -168,7 +164,6 @@ public class GdxMap implements ApplicationListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render() {
|
public void render() {
|
||||||
// Log.d("yo", )
|
|
||||||
// GLState.enableVertexArrays(-1, -1);
|
// GLState.enableVertexArrays(-1, -1);
|
||||||
// GLState.blend(false);
|
// GLState.blend(false);
|
||||||
// GLState.test(false, false);
|
// GLState.test(false, false);
|
||||||
@ -281,6 +276,22 @@ public class GdxMap implements ApplicationListener {
|
|||||||
mMapView.updateMap(false);
|
mMapView.updateMap(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Input.Keys.G:
|
||||||
|
if (mGridLayer == null) {
|
||||||
|
mGridLayer = new GenericOverlay(mMapView, new GridRenderLayer(mMapView));
|
||||||
|
mGridLayer.setEnabled(true);
|
||||||
|
mMapView.getLayerManager().add(mGridLayer);
|
||||||
|
} else {
|
||||||
|
if (mGridLayer.isEnabled()) {
|
||||||
|
mGridLayer.setEnabled(false);
|
||||||
|
mMapView.getLayerManager().remove(mGridLayer);
|
||||||
|
} else {
|
||||||
|
mGridLayer.setEnabled(true);
|
||||||
|
mMapView.getLayerManager().add(mGridLayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mMapView.render();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user