Graphics do not show up after upgrading to latest SDK (10.1.1)

720
1
Jump to solution
07-05-2013 08:37 AM
OguzhanTopsakal
New Contributor III
I searched for an answer about this issue but could not find..

I upgraded the SDK to 10.1.1 and now graphics that I add to the graphics layer do not show up. I am copy pasting my code below. I removed [graphicsLayer dataChanged] method call since it is removed with the new SDK.

============

    NSString *imageName = @"Orange.png";     // Creates a custom marker symbol with the picture     AGSPictureMarkerSymbol *myMarkerSymbol = [AGSPictureMarkerSymbol pictureMarkerSymbolWithImageNamed:imageName];     // Gets the size for the node     float diameter = 50.0;         myMarkerSymbol.size = CGSizeMake( diameter, diameter );          // Converts latitude and longitude values to mercator  double num = longtitude * 0.017453292519943295;  double x = 6378137.0 * num;  double a = latitude * 0.017453292519943295;  double mercatorX = x;  double mercatorY = 3189068.5 * log((1.0 + sin(a))/(1.0 - sin(a)));    //Create an AGSPoint (which inherits from AGSGeometry) that  //defines where the Graphic will be drawn  AGSPoint* myMarkerPoint = [AGSPoint pointWithX:mercatorX              y:mercatorY           spatialReference:self.mapView.spatialReference];          //NodeInfoTemplate handles what needs to be written in the callout window  NodeInfoTemplate *template = [[NodeInfoTemplate alloc] init];  //Create the Graphic, using the symbol and geometry created earlier  AGSGraphic* myGraphic =[AGSGraphic graphicWithGeometry:myMarkerPoint              symbol:myMarkerSymbol             attributes:nodeDict            infoTemplateDelegate:template];       //Add the graphic to the Graphics layer  [self.graphicsLayer addGraphic:myGraphic];

============

Note that I removed the following line since dataChanged method is removed with the new SDK.
[self.graphicsLayer dataChanged];
0 Kudos
1 Solution

Accepted Solutions
OguzhanTopsakal
New Contributor III
I figured out what I was doing wrong.. I was reinitializing the graphics layer while I should not:

    self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];



I was using the following code to remove previous graphics in the old SDK:
    [self.graphicsLayer.graphics removeAllObjects];


After the upgrade, I figured, I need to use the following code instead:
    [self.graphicsLayer removeAllGraphics];


I hope this helps to somebody..

View solution in original post

0 Kudos
1 Reply
OguzhanTopsakal
New Contributor III
I figured out what I was doing wrong.. I was reinitializing the graphics layer while I should not:

    self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];



I was using the following code to remove previous graphics in the old SDK:
    [self.graphicsLayer.graphics removeAllObjects];


After the upgrade, I figured, I need to use the following code instead:
    [self.graphicsLayer removeAllGraphics];


I hope this helps to somebody..
0 Kudos