self.mapView.calloutDelegate = self;
Record *record = (Record*)[pointArray objectAtIndex:0]; NSMutableDictionary *attributeDictionary = [record mutableDictionaryForRecord]; // Create attributes dictionary from record object [attributeDictionary setObject:record.legendID forKey:legendAttribute]; // Add legendID for legend attribute to be used by renderer AGSPoint *point = [AGSPoint pointWithX:record.x y:record.y spatialReference:_sourceMapManager.map.spatialReference]; AGSCalloutTemplate* template = [[AGSCalloutTemplate alloc] init]; template.titleTemplate = @"${legendLabel}"; template.detailTemplate = @"${address}"; // Create graphic AGSGraphic *graphic = [AGSGraphic graphicWithGeometry:point symbol:nil attributes:attributeDictionary infoTemplateDelegate:template]; [_sourceGraphicsLayer addGraphic:graphic]; [_graphicTemplates addObject:template];
Solved! Go to Solution.
I use a unique value renderer and a graphics layer in my map. The UVR symbolizes my graphics correctly, however when I add a simple info template delegate to each of my graphics in it's initializer tapping (or clicking) in simulator does not fire:
...
I add the info template like this to my graphics. Record is a simple object I use to encapsulate data. Note that my template is added to a local mutable array of template object so as to be retained. When the app starts up the points are displayed correctly, but tapping on the graphics doesn't do anything. What am I doing wrong?
I am confused as to how the AGSMapViewCalloutDelegate and the Graphics's infoTemplateDelegate work together.
Does this have anything to do with passing in a nil symbol and allowing the renderer to symbolize the graphics? I've read the docs and it doesn't appear to say anything about this.
I use a unique value renderer and a graphics layer in my map. The UVR symbolizes my graphics correctly, however when I add a simple info template delegate to each of my graphics in it's initializer tapping (or clicking) in simulator does not fire:
...
I add the info template like this to my graphics. Record is a simple object I use to encapsulate data. Note that my template is added to a local mutable array of template object so as to be retained. When the app starts up the points are displayed correctly, but tapping on the graphics doesn't do anything. What am I doing wrong?
I am confused as to how the AGSMapViewCalloutDelegate and the Graphics's infoTemplateDelegate work together.
Does this have anything to do with passing in a nil symbol and allowing the renderer to symbolize the graphics? I've read the docs and it doesn't appear to say anything about this.
Apologies for asking the obvious, but are you sure you are instantiating the NSMutableArray that retains your templates before it is being used? XCode gives you no instant, compile, or run time warning if you are attempting to call a nil object, and calling addObject: on an uninitialized NSMutableArray will not cause a crash, but will cause the same memory management issues that would arise from not adding the object to the array.