[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| [udig-devel] Re: FW: Add layer programmatically/1.1 question | 
My understanding the two are very similar;
- option one sends the AddLayerCommand to the map
- option 2 creates a bunch of layers from the provided list of 
GeoResources and inserts these new layers at the indicated position.
There have been a number of off lists questions about creating and 
managing maps "by hand"; in general you can ignore all the udig stuff 
and create your own MapCommand; in the body of the command you can do 
anything you want...
Jody
Stephen Kilburn wrote:
To add a layer programmatically,
http://udig.refractions.net/confluence/display/DEV/How+do+I+add+a+layer+prog
rammatically says:
-for uDig 1.0:
  IMap map;
  map.sendCommandASync(new AddLayerCommand(layer) );
-for uDig 1.1:
  ApplicationGIS.addLayersToMap(map, layers, startposition, project);
But addLayersToMap takes a List<IGeoResource>, not a List<ILayer>, and when
I try:
  Layer layer = ProjectFactory.eINSTANCE.createLayer();
  // ... populate the new layer with geo and styling ...
  IGeoResource igr = (IGeoResource) layer;
I get a ClassCastException.
Do I need to use the 1.0 syntax to add *layers* or am I missing something?
(Latter exceedingly likely!)
_____________________________________________________________
Stephen Kilburn, GeoPraxis Inc.