Adding a graphics layer
A graphics layer is the container for your graphics. The graphics layer will need to be added to the JMap. A graphics layer can also be contained in a group layer. A JMap can contain a number of graphics layers.
The following code shows how a graphics layer is created and added to an existing JMap:
//create a map
map = new JMap();
window.getContentPane().add(map);
//...maybe add a tiled layer to the map...
//create and add a graphics layer to a map
GraphicsLayer myGraphicsLayer = new GraphicsLayer();
map.getLayers().add(myGraphicsLayer);
The graphics layer is now ready to have graphics added to it which will be displayed in the JMap. Graphics to be added to a graphics layer will be created as follows:
- Create a symbol which defines how the graphic will be presented
- Create a geometry which represents where the graphic will be displayed
- Finally create a graphic which uses the defined symbol and geometry. This is the item which is added to the graphics layer.
2/7/2013