I am displaying one of the sample feature layers from ArcGIS online on my map and I want to show a callout when a graphic on the feature layer is selected (tapped).
Following is a code snippet ..
- (void)viewDidLoad
{
[super viewDidLoad];
self.mapView.callout.delegate = self;
...
NSURL *featureLayerURL = [NSURL URLWithString:@"http://services.arcgis.com/oKgs2tbjK6zwTdvi/arcgis/rest/services/Major_World_Cities/FeatureServer/0"];
AGSFeatureLayer *featureLayer = [AGSFeatureLayer featureServiceLayerWithURL:featureLayerURL mode:AGSFeatureLayerModeOnDemand];
[self.mapView addMapLayer:featureLayer withName:@"CloudData"];
...
}
-(BOOL)callout:(AGSCallout *)callout willShowForFeature:(id<AGSFeature>)feature layer:(AGSLayer<AGSHitTestable> *)layer mapPoint:(AGSPoint *)mapPoint
{
//Specify the callout's contents
self.mapView.callout.title = (NSString*)[feature attributeForKey:@"NAME"];
self.mapView.callout.detail =(NSString*)[feature attributeForKey:@"COUNTRY"];
return YES;
}
However this sets title and details as nil, even though when I call this from the desktop browser (http://www.arcgis.com/home/webmap/viewer.html?url=http://services.arcgis.com/oKgs2tbjK6zwTdvi/ArcGIS...) it shows the name, country and other attributes.
What am I missing here? Is there a way to show the attributes/fields of the feature being selected? Any examples will be helpful too.
Thanks