Creating a Graphics layer
Graphics layers allow you to dynamically display graphics on a Map. A Graphics layer could, for example, be used to hold polygons or lines drawn by a user or display features that satisfy the results of a task such as query or geoprocessing. In the image below, a Graphics layer is used to show states that have a population density of more than 200 per square mile:
When you want to add a Graphics layer to the map, you will use the AGSGraphicsLayer class to create your layer. Instances of this class contain a list of graphics and an optional renderer (AGSRenderer). There are also methods for adding, removing, and redrawing graphics. Be sure to add the Graphics layer after any base layers so that the Graphics will display above those layers when you run your application. For more information, refer to the overview topic for layers.
How to add a Graphics layer
If you have not already done so, create an application with a Map as described in the topic Displaying A Map. Then create your layer as follows:
AGSGraphicsLayer* myGraphicsLayer = [AGSGraphicsLayer graphicsLayer];
If you want to reference your new Graphics layer in another method, you can create an instance variable in your class to hold the Graphics layer.
To add the new Graphics layer to the map, use the AGSMapView method addMapLayer:
UIView* graphicsView = [self.mapview addMapLayer:myGraphicsLayer withName:@"Graphics Layer"];
The addMapLayer method returns a UIView. The graphics in the Graphics layer are drawn into this view. You can use this view to hide or show graphics in response to user actions. If you do not need access to the view containing the Graphics layer, you can simply do this:
[self.mapview addMapLayer:myGraphicsLayer withName:@"Graphics Layer"];
Note that the name you give your layer in the addMapLayer method must be unique to your map view.
Adding graphics to your Graphics layer is described in the Managing Graphic features document.