Dashboard > UDIG Developer Guide > Home > 5 FAQ > GIS Application Questions > How do I create a map programmatically
How do I create a map programmatically Log In | Sign Up   View a printable version of the current page.

Added by Jesse Eichar , last edited by Administrator on Nov 16, 2007  (view change)
Labels: 
(None)

Q: How do I create a map programmatically?

A:
uDig 1.0.x branch:

Project owner = // somehow get a project
String name="MapName";

// create the map
IMap map = ProjectFactory.eINSTANCE.createMap(owner, name, new ArrayList());

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);

uDig 1.1.x branch:

CreateMapCommand command=new CreateMapCommand("MapName", listofGeoResources, project);
project.sendSync(command);
IMap map=command.getCreatedMap();
Powered by a free Atlassian Confluence Open Source Project License granted to uDig. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators
User-friendly Desktop Internet GIS