Map API

Nutiteq Maps Lib SDK enables developing advanced mobile mapping applications.
Platforms: Android, RIM BlackBerry, Java ME (J2ME)
Download maps API SDK »
Untitled Document

Products

» View demos
» Downloads

Latest news

Last at Tue, 3 Apr 2012 23:31:42
Topic: MapXT SDK evaluation
See more news »

WMS as Overlay

5 replies [Last post]
MartinD
User offline. Last seen 20 weeks 1 day ago. Offline
Joined: 12/22/2011

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?

AttachmentSize
SimpleWMSMap.java2.95 KB
TileOverlay.java603 bytes
jaak
User offline. Last seen 15 hours 50 min ago. Offline
Joined: 06/19/2008

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

MartinD
User offline. Last seen 20 weeks 1 day ago. Offline
Joined: 12/22/2011

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)

jaak
User offline. Last seen 15 hours 50 min ago. Offline
Joined: 06/19/2008

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.

/JaakL

MartinD
User offline. Last seen 20 weeks 1 day ago. Offline
Joined: 12/22/2011

Thanks for the help. I'll try that and report back!