Hi ,
I am new to UDIG I want to display a default map when a RCP
application is started. I am following RCP tutorial.
I am able to add the layer to the map but not able to view
the map. I am using the countries.shp file available with demo
data.
I have added following piece of code in createPartControl() method of MapView class
ProjectRegistry projectRegistry
= ProjectPlugin.getPlugin().getProjectRegistry();
Project udigProject = projectRegistry.getProject("D:\\Example
Resources\\ProjectTemplates\\temp.udig");
List<IMap> list = udigProject.getElements(IMap.class);
IMap map1 = list.get(0);
List<ILayer> projectLayers = map1.getMapLayers();
System.out.println("projectLayers" +
map1.getName() + "layerCount : " + projectLayers.size() + " bounds
: " + map1.getBounds(null).getMinX());
map = (Map) map1 ;
map.sendCommandSync(BasicCommandFactory.getInstance().createAddManyLayers(projectLayers));
ReferencedEnvelope bounds = map.getViewportModel().getBounds();
System.out.println("Bounds
are : " + bounds.getMinX() + bounds.getMaxX());
map.getViewportModelInternal().setBounds(bounds);
map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
map.sendCommandASync(new
SetViewportBBoxCommand(bounds));
mapviewer.setMap(map);
The printMapAction shows the name of the layer and the
information that the layer is visible , but the map is not shown .
I followed similar forums and found out the extent needs to
be set for display of the map. I am trying to set the bounds and CRS through
these statements.
map.getViewportModelInternal().setBounds(bounds);
map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
map.sendCommandASync(new
SetViewportBBoxCommand(bounds));
Am I missing something or doing
something wrong ? I am able to get and set the bounds of
Viewport but cannot find any method to set the bounds of
the Map object.
Appreciate, if I can get some insight in this scenario.
Thanks & Regards
Nidhi