[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[udig-devel] How to use MapViewer to display WMS layers ?
|
Hi,
I am a newvbie with uDig. I need to display a map with WMS layers in
my own Eclipse RCP application.
I try to use MapViewer but I can't make it work. The viewport is
blank, no GetMap requests are sent to my WMS server (but the
GetCapabilities request is sent OK)
I wrote the following code :
private MapViewer viewer;
private Map map;
public void createPartControl(Composite parent) {
try {
FillLayout fillLayout = new FillLayout();
fillLayout.type = SWT.VERTICAL;
parent.setLayout(fillLayout);
CatalogPlugin cp = CatalogPlugin.getDefault();
IServiceFactory sf = cp.getServiceFactory();
List<IService> services = sf.createService(new
URL("http://10.9.1.30:8080/maquette-web/proxy/wms"));
List<IGeoResource> resources = new ArrayList<IGeoResource>();
for ( IService service : services) {
for (IResolve resolve : service.resources(new NullProgressMonitor())) {
IGeoResource resource = (IGeoResource) resolve;
resources.add(resource);
}
}
map = (Map) ProjectFactory.eINSTANCE.createMap();
LayerFactory layerFactory = map.getLayerFactory();
List<Layer> toAdd=new ArrayList<Layer>(resources.size());
for( IGeoResource resource : resources ) {
Layer layer = layerFactory.createLayer(resource);
toAdd.add(layer);
}
map.getLayersInternal().addAll(toAdd);
viewer = new MapViewer(parent, SWT.MULTI | SWT.NO_BACKGROUND);
viewer.init(this);
viewer.setMap(map);
} catch (Exception e) {
e.printStacktrace();
}
}
The layers are well set (map.getLayersInternal() is OK) but no tile is
displayed. No message, I have no idea what happens.
I surely made something wrong, but what ?
Thanks for any help
Olivier