sum_chat

not able to add a polyline to a graphics layer

Discussion created by sum_chat on Mar 13, 2011
Latest reply on Mar 15, 2011 by njarecha-esristaff
Hi,
I am trying to add a polyline to a graphics layer. But it is not getting displayed although it is not giving any error.
Any help is highly appreciated!!
Thanks
Suman

The code is as below:

-(void)drawLine{
GisAppAppDelegate *mapDelegate =(GisAppAppDelegate *)[[UIApplication sharedApplication] delegate];
    int i= [mapDelegate.geomObject count];// geomObject is a mutableArray in which I am storing the AGSPoint on map click
if(i >= 2){
AGSMutablePolyline *polyline = [[AGSMutablePolyline alloc] initWithSpatialReference:self.mapView.spatialReference];
AGSSimpleLineSymbol *ln1=[AGSSimpleLineSymbol simpleLineSymbol];
ln1.color = [UIColor colorWithRed:9 green:0 blue: 0 alpha:0.5];
ln1.width = 5.0;
ln1.style = AGSSimpleLineSymbolStyleSolid;

[polyline addPathToPolyline];
         for (int x1=0; x1< i; x1++) {
  AGSPoint *mappoint= [self.geomObject objectAtIndex:x1];
 
  [polyline addPointToPath:[AGSPoint pointWithX:mappoint.x y:mappoint.y spatialReference:nil]];
 

      }
AGSGraphic *line=[[AGSGraphic alloc] initWithGeometry:polyline symbol:ln1 attributes:nil infoTemplateDelegate:nil];
          [self.myGraphicsLayer removeAllGraphics];
  [self.myGraphicsLayer addGraphic:line];

         [self.myGraphicsLayer dataChanged];
   }
}

Outcomes