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];
[self.graphicsLayer dataChanged];
Solved! Go to Solution.
self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];
[self.graphicsLayer.graphics removeAllObjects];
[self.graphicsLayer removeAllGraphics];
self.graphicsLayer = [AGSGraphicsLayer graphicsLayer];
[self.graphicsLayer.graphics removeAllObjects];
[self.graphicsLayer removeAllGraphics];