Hi,
I am trying to display a OSM map with a custom street network from my own Geoserver WMS as an overlay.
So far among other things I tried this with no luck:
SimpleWMSMap wms = new SimpleWMSMap(
"http://exampleWms/wms?version=1.1.0&SRS=EPSG:4326",
256, 0, 18,"exampleLayer", "image/jpeg",
"", "GetMap", "");
wms.setWidthHeightRatio(2.0);
mapComponent.getMap().addTileOverlay(wms.getTileOverlay());
Displaying only my WMS with mapComponent.setMap(wms) works fine, so there is not the problem.
Can anyone help?
| Attachment | Size |
|---|---|
| SimpleWMSMap.java | 2.95 KB |
| TileOverlay.java | 603 bytes |
I can only see the basemap, nothing else. Here is my complete onCreate() method:
public void onCreate(Bundle savedInstanceState) {
onRetainCalled = false;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapComponent = new BasicMapComponent("tutorial", new AppContext(this), 1, 1, new WgsPoint(7.65, 52.00), 10);
mapComponent.setMap(OpenStreetMap.MAPNIK);
mapComponent.setPanningStrategy(new ThreadDrivenPanning());
mapComponent.startMapping();
// get the mapview that was defined in main.xml
MapView mapView = (MapView)findViewById(R.id.mapview);
// mapview requires a mapcomponent
mapView.setMapComponent(mapComponent);
ZoomControls zoomControls = (ZoomControls)findViewById(R.id.zoomcontrols);
// set zoomcontrols listeners to enable zooming
zoomControls.setOnZoomInClickListener(new View.OnClickListener() {
public void onClick(final View v) {
mapComponent.zoomIn();
}
});
zoomControls.setOnZoomOutClickListener(new View.OnClickListener() {
public void onClick(final View v) {
mapComponent.zoomOut();
}
});
SimpleWMSMap wms = new SimpleWMSMap(
"http://giv-arg.uni-muenster.de:8080/geoserver/AlternateRealityGame/wms?version=1.1.0&SRS=EPSG:4326",
256, 0, 18,"AlternateRealityGame:roads", "image/jpeg",
"", "GetMap", "");
wms.setWidthHeightRatio(2.0);
mapComponent.getMap().addTileOverlay(wms.getTileOverlay());
}
When I replace the addTileOverlay(...) by "mapComponent.setMap(wms);" I can see my WMS layer.
I added the actual WMS Url to the code sample, so you can better see what I am doing. The WMS server is a Geoserver (wms?version=1.1.0)
You cannot use ordinary Map as Overlay, overlay is different object in current Nutiteq SDK. If you have [URL]/z/x/y.png style server, then you can add overlay to current map with following code (hill shading overlay):
mapComponent.getMap().addTileOverlay(new TileOverlay("http://toolserver.org/~cmarqu/hill"));
mapComponent.refreshTileOverlay();
After this you can use getTileOverlay() if needed, in your code getTileOverlay() returns null. It seems I don't have readymade WMSOverlay, but you can use attached TileOverlay.java and SimpleWmsMap.java - just take the code from WMS buildPath method and put it to TileOverlay.getOverlayTileUrl() method. Or create more universial OverlayFromMap(UnstreamedMap) class.
Thanks for the help. I'll try that and report back!
What is your basemap, it should be also EPSG:4326 ? How does this does not work exactly look like - see something strange or only base map?
/JaakL